We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I have this bit of code in preload()
function preload() {
let gamename = "test";
let fdat = loadStrings("games/"+gamename+".bit");
console.log(fdat);
fdata = fdat;
}
And the file "test.bit" reads:
block
50
110
200
200
0
255
0
floor
50
100
200
10
0
255
0
But what I get in console is an array containing the values:
"block"
"50"
"110"
"200"
"200"
"0"
"255"
"0"
Even though the file reads what is above.
The array should read:
"block"
"50"
"110"
"200"
"200"
"0"
"255"
"0"
"floor"
"50"
"100"
"200"
"10"
"0"
"255"
"0"
I have no idea why this happens, can someone explain?
Answers
so fdat is an array of type string (or can be)
maybe it's just cut in console, did you try any other way of output such as for loop over it? Maybe fdat itself is ok?
i think he's trying to print the array before it's fully loaded - it's called preload for a reason...
https://p5js.org/reference/#/p5/preload
I see.
How can we detect if loading is over?
read the preload reference? 8)
(setup blocks until preload is finished)
ah, and in turn draw waits till setup is done
thanks!
Can you host your sketch at the link below along w/ your "test.bit" file:
https://OpenProcessing.org/sketch/create
So we can also run it and check what's going wrong w/ it? :-?
This was just a caching problem.