Hello. As the title suggests I'm having problems displaying sprites in a nested for loop. It's basically a bit of code designed to arrange 24 sprites on an 8x3 grid, however I'm having a problem with showing animated sprites, here's the bit that's not working:
if _GUI_CURRENT_FOLDER=4
//Deletes all sprites so that new ones can be drawn
for _IMAGE = 1 to 24
if sprite exist(_IMAGE+1) then delete sprite (_IMAGE+1)
NEXT _IMAGE
//sets the directory to the folder where monster
//information is stored.
set dir _TOTAL_PATH$ : set dir "Resources" : set dir "Monsters"
for _IMAGE=1 to 24
if file exist(str$(_IMAGE)+".MONSTER")
//gets the name of the sprite sheet
//(the first string in the file isn't needed so I skip it.
open to read 10, str$(_IMAGE)+".MONSTER"
read string 10, _NULL$ : read string 10, _MONSTER_SHEET$
close file 10
//Returns to parent directories
set dir ".." : set dir ".."
//Opens the directory containing the sprite sheets
set dir "Resources" : set dir "Sprites"
//Creates the animated sprite
create animated sprite (_IMAGE+1), _MONSTER_SHEET$, 3, 4, (_IMAGE+1)
//Positions the sprite to the grid.
sprite (_IMAGE+1), 592+(((_IMAGE mod 8)*48)+((_IMAGE mod 8)*3)), 543+((_CURRENT_LINE*48)+(_CURRENT_LINE*3)),(_IMAGE+1)
//Sets sprite frame to looking forward
set sprite frame (_IMAGE+1), 8
set dir ".." : set dir ".."
//Checks if the row is completed and starts a new one.
if (_IMAGE mod 8) = 0 then inc _CURRENT_LINE
else
//Writes a new file to inform me if it failed to open
open to write 10, "FAIL"
write string 10, str$(_IMAGE)+".MONSTER"
close file 10
set dir ".." : set dir ".."
break
endif
NEXT _IMAGE
ENDIF
(I hope that makes sense, my coding isn't particularly brilliant)
It does that on every loop at the moment (going to change it to only do that when required after I get it working). It will load the first monster file fine, but after that it doesn't show any more, I don't get any error messages and the fail file isn't made so the monster file must exist. any suggestions as to why or any possible solutions??
(p.s. here's the layout for the monster file in case you don't get why I'm skipping the first string)
monstername$ (string)
spritesheet$ (string)
attack (byte)
defence (byte)
speed (byte)
edit: FIXED. I was telling it to go to the wrong location, my bad.