I’ve made a game where you could design aquariums for the Ocean Jam. (No copying please!) I’m having trouble with loading a game state. For whatever reason, the for
loop only runs once and only spawns in the first thing created.
Press B
to open a menu. Hopefully, the rest is self-explanatory. If you place something down, you can select it with A
and bring up a “right-click” menu with B
. If you aren’t selecting anything it’s like right-clicking the background.
This is the problem part:
function load_aquarium(name: string): boolean {
let save_name: string = "aquarium_simulator_save_" + name + "_sprite_count"
if (blockSettings.exists(save_name)) {
console.logValue(save_name, blockSettings.readNumber(save_name))
let i: number = 0
// Here
// Problem is that while loop exits too early
for (let i = 0; i < blockSettings.readNumber(save_name); i++){
save_name = "aquarium_simulator_save_" + name + "_sprite_" + i + "_"
let index: number = blockSettings.readNumber(save_name + "index")
console.logValue(save_name + "index", blockSettings.readNumber(save_name + "index"))
console.logValue(save_name + "x", blockSettings.readNumber(save_name + "x"))
console.logValue(save_name + "y", blockSettings.readNumber(save_name + "y"))
console.logValue(save_name + "z", blockSettings.readNumber(save_name + "z"))
let sprite_thing = summon_thing(
blockSettings.readNumber(save_name + "x"),
blockSettings.readNumber(save_name + "y"),
blockObject.getStringProperty(shop_list[index], StrProp.name),
index,
blockObject.getImageProperty(shop_list[index], ImageProp.regular_image),
blockObject.getImageProperty(shop_list[index], ImageProp.selected_image)
)
sprite_thing.z = blockSettings.readNumber(save_name + "z")
}
return true
}
return false
}
Hmmm…I meant for
loop instead of while
loop in the comment above.
If you are confused about how it works, please tell me!
Thanks in advance!