Saving Types
BlitzPlus Forums/BlitzPlus Programming/Saving Types
| ||
I'm Trying to save types, and when loading, replace the values in each of the types with the ones that had been saved, eg: ;--------- (saving preperation etc) for d.door=each door d\open=writeint(save, d\open) next (loadingpreperation etc) for d.door=each door d\open=readint(load, d\open) next ;--------- It works. It reads the variable correctly, but when i for example open a locked door, and then load from the last saved file, that door will now be open, not locked. any ideas on why? Could it be anything to do with locked doors having 'd\open'=0 (as default)? |
| ||
So either the save file is being changed from what you expect, or it's not loading it right, or the door is being changed after you reload. Can you figure out which one? |
| ||
if i load the doors open value(=0)and its currently=1, then it remains=1, but when i load it(=1) and its currently=0, it works and loads it=1 load(0): if 1 remains 1 load(1): if 0 becomes 1 |
| ||
If this were C I'd say you could be getting == and = mixed up... =) Could you post some more code? |
| ||
d\open=writeint(save, d\open) Why would you change the variable as you save it? Shouldn't this just be:writeint(save, d\open) |
| ||
oh, duh. sharp eye, wolron! since writeint returns true, open=1! pblt[pth |
| ||
oops, thats just me remmembering my code wrongly: Heres the actual code: |
| ||
Bump: |
| ||
There's nothing wrong with that code; the problem is elsewhere. |
| ||
Assuming the doors are in the same order in memory that they were when they were saved... |
| ||
yep: All created when the program begins in the exact same order every time. |
| ||
So if the guesses we've already made aren't enough for you, we'll need more information (i.e. code) |
| ||
When you load your doors, have you create them with new??Repeat D.Door=New Door D\Door=ReadInt(Loadstate) Until Eof(Loadstate) |
| ||
no, i just declare the variable equal to read integer like so: i'll try that if all else fails, but it i'd like to get it working the way it is |
| ||
Hi What I suggest is that when you load a saved game, you delete all the level's current info and then recreate the level using the saved info. That way, you eliminate 'update' errors and could then see if all the data is actually being saved correctly. Example Code: Delete Each Door LevelFile=ReadFile("Level.dat") No_Of_Doors = ReadInt(LevelFile) ;Doors in the level is the first thing saved in the datafile For N=1 to No_Of_Doors doors.Door = New Door doors\open = ReadInt(LevelFile) . . (Other Data) . Next CloseFile(LevelFile) Another cause of your problem might be to do with what your saving - Be careful if you're saving loads of variable length strings as they could be overwriting the data which concerns the doors' open/closed status. Hope this helps! Ryan P.S. How do you insert code into a forum post with the black background and green text format? |
| ||
{codebox} code goes here {/codebox} Like that, only with square brackets I do reload the level, its just that doors and treasure chests are not reloaded, as wether the have been opened or not, is constant throughout the game (rpg) i dont want to read a file for each area because then i'd have to have one, for each area, for each savestate. It could be done (eg: readfile(savestatename$+"a_1") but with several hundred areas id prefer having one savestate file for each game user. i could of course opt to go to a particular line to read, but that would end up getting really messy. I geuss i'll just have to try deleting all the doors themselves, then recreating them with the read integer (like tiger said:thanks) Thanks 4 everyones help. strangely though the treasure chests work fine.. yet the same way. This battle may not be won yet! ps:i,ve not quite got to the place of saving strings, but when i do that'll come in handy, thanks Ryan. (i'm leaving the main game menu till last, so i can test things really quickly) Edit: Thanks, Its working now!------------------------>>:) |