Saving and Loading Variables Issue

Support for version 4.9 and earlier.

Saving and Loading Variables Issue

Postby Wellington2k » July 23rd, 2011, 4:34 pm

Hello. I want to have it where I can save the last score of the game, but every time I try load a variable I get 0.

Here is the code.

Room_1


If A == true
If Button Press Newpress;A
Set Variable A;false
Set Sprite Frame 0;0;PA_RandMinMax(1,3)
Set Variable Score;Score+1
End If
End If
If B == true
If Button Press Newpress;B
Set Variable B;false
Set Variable Score;Score+1
Set Sprite Frame 0;0;PA_RandMinMax(2,3)
End If
End If
If X == true
If Button Press Newpress;X
Set Variable X;false
Set Sprite Frame 0;0;PA_RandMinMax(0,1)
Set Variable Score;Score+1
End If
End If
If Y == true
If Button Press Newpress;Y
Set Variable Y;false
Set Sprite Frame 0;0;PA_RandMinMax(0,2)
Set Variable Score;Score+1
End If
End If
If PA_GetSpriteAnimFrame(0,0) == 0
Set Variable A;true
End If
If PA_GetSpriteAnimFrame(0,0) == 1
Set Variable B;true
End If
If PA_GetSpriteAnimFrame(0,0) == 2
Set Variable X;true
End If
If PA_GetSpriteAnimFrame(0,0) == 3
Set Variable Y;true
End If
Draw Variable 1;12;11;Score
Declare Global timer;Whole Number;60*60
Set Variable timer;timer-1
If (timer) <= 0
Switch Room Room_2
End If
Draw Variable 1;11;3;timer/60
Declare Global Score;Whole Number;0
Declare Global ScoreSaved;Whole Number;0



Room_2


Output Text 1;5;16;You got
Draw Variable 1;13;16;Score
Output Text 1;17;16;points!
Draw Variable 0;10;12;ScoreSaved
If ScoreSaved == 0
Set Variable ScoreSaved;Score
End If
If Sprite Touched 0
Save Variable ScoreSaved
End If
If !ScoreSaved == 0
Load Variable ScoreSaved
Set Variable ScoreSaved;ScoreSaved
End If


Thanks! I'm going to delete the code in 3 days from this post.
Wellington2k
 
Posts: 29
Joined: July 21st, 2011, 10:32 pm

Re: Saving and Loading Variables Issue

Postby bksonic » July 23rd, 2011, 4:40 pm

Have you initialised FAT? Are you testing it on an emulator (saving and loading does not work on an emulator).
Have you played Sliker DS?

Why not try Everything's A Lie? (For Windows PC)
or for DS
User avatar
bksonic
 
Posts: 122
Joined: December 30th, 2010, 9:54 pm
Location: Somewhere I Belong

Re: Saving and Loading Variables Issue

Postby Wellington2k » July 23rd, 2011, 5:06 pm

I init FAT but when I try to load a saved score it shows 4. When I save a new number it doesn't seem to save, because it still shows 4. Any help?
Last edited by bksonic on July 23rd, 2011, 11:19 pm, edited 1 time in total.
Reason: No double-posting.
Wellington2k
 
Posts: 29
Joined: July 21st, 2011, 10:32 pm


Return to DSGM 4.9

Who is online

Users browsing this forum: No registered users and 1 guest

cron