DATA and RESTORE query
Blitz3D Forums/Blitz3D Beginners Area/DATA and RESTORE query
| ||
I'm working on a small project, and rather than making a level editor (until I get the actual code working as expected), I'm just using DATA statements. The sections are called .level1, .level2 etc, but I'm currently having to "RESTORE level1" to read the data for that level (and then RESTORE level2 to get the next one). Is there an easy way to combine the level number with the label so I can just have code at the end of level section which looks like "RESTORE level+lvlNumber"? |
| ||
Not that I'm aware of, but you can restire to the first level, then when you are done with the first, just use Read again without Restore, the Read will start where it left off.Restore level1 ;set the next read to .level1 For x = 1 to 10 Read level1data(x) Next for x = 1 to 10 Read level2data(x);no need for Restore here, it'll start at the next piece of data Next .level1 Data 0,1,2,3,4,5,6,7,8,9 .level2 Data 9,8,7,6,5,4,3,2,1,0 |
| ||
I'm afraid not :S What you could do is read all your levels into types. Then when it comes to loading in a level, load the data from the type into the program and load the level using that info. Since your levels will probably be file path names and such, it should really be too much data. |
| ||
Thanks for the help! The Blitz help screen confused me - I thought you HAD to restore to each part. Now I can just put them one after the other, and that should do the trick. |
| ||
Actually, you don't really need Restore at all. Blitz will begin at the first Data element when started. However it is good practice to do a Restore at the beginning. In case if you ever want to restart the program internally, say after all the player's men die, then you know that the next time, all the data will be read from the beginning. |