ScriptCraft

ScriptCraft

14.6k Downloads

scload("myData.json") returns null

leumasme opened this issue ยท 3 comments

commented

I was trying to load some JSON-Data from a file. That didnt work because scload kept returning null.
Then i tried replicating the situation in the API-Reference: I made a file called myData.json with the example JSON data for scload in it in the plugins folder, made a new script in the same folder and put the following code in it:

var myData = scload("myData.json");
console.log(myData)

And yeah, it still logs [scriptcraft] null in the console. w h y t h o

commented

// Sidequestion: Can you log stuff to the console without the [scriptcraft] in front?

commented

// Sideanswer: try /js server.consoleSender.sendMessage("something")

commented

Also scload with a relative path will start looking in the server's root directory, e.g. scload("ops.json") should return something. Try using the full path to your JSON file.