Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

"Restarting" chapters and variables

12 years ago

In my game, since it is very long. I want to give the player the option to start over from the beginning of their current chapter should they reach a "game over". However, I also have a lot of complex variables that would need to return to the way they were originally when the player first started that chapter. 

Is there is a script to reset the variables back to what they were at the start of a chapter(without messing up the player's scores in previous chapters). Previous button won't work because there may be more than one page that led to that ending so it would need anywhere between 2-4 previous buttons and it could mess up variables(I could be wrong though).

If I just rig the link to remove all progress they could have made in the variables for that one chapter, then I would have to account for all possible paths they could have chosen and what resulting scores they would have achieved. Then make the link(s) appear/not appear based on their scores so that I don't subtract scores that weren't affected that chapter.

Any suggestions?

"Restarting" chapters and variables

12 years ago

The best way to go about this is to do the following:

Create a copy of every variable you want to save with the prefex CHP2 so:

CHP2Score
CHP2Health

etc, etc.

At the beginning of chapter 2, use a script to make CHP2Score = Score and CHP2Health = Health, etc, etc. On the "Reset to Chapter 2 link", set Score = CHP2Score, Health = CHP2Health, etc. You'll have to create a new variable set for each new chaper.

My advice: Definitely not worth your time. 99% of the users will just use the back button rather than resetting anyway.

"Restarting" chapters and variables

12 years ago

Yeah, I'd have to recreate over 13 variables per chapter(5 chapters, and 9 versions of chapter 5). I think I'll risk ticking people off by having to start all over or hit the back button.

Thanks 3J :D

"Restarting" chapters and variables

12 years ago

And it's just cleaner that way too. No chance for mistakes and exploitable bugs.

"Restarting" chapters and variables

12 years ago

3J is correct about folks not being likely to use a Restart Link vs. the Back Button (that’s why so few have ever finished the Jurassic Fairview Park game, hehehe). If you really want to try it though, it might be doable without too much trouble if you use a Global Script.

Hint – Don’t worry about creating all the New Saved Variables in the Variables Page. You can skip that when using Scripts.

Let’s try this with an example list of Variables:

 

%HEALTH

%AGE

%FRIENDS

%ENEMIES

%DRAMA

%GOLD

 

At the start of each new Chapter, I want to take a snapshot of these and have them reset when I click on a ‘Restart’ Link that takes me back to the Chapter in Question.

First, I’ll make a note of the Page# of the Staring Page of all the Chapters I want ‘Restartable’. Let’s say:

Chapter 1: Page 1; Chapter 2: Page 200; Chapter 3: Page 300; & Chapter 4: Page 400

Next, I create a Global Script: (where ZZVARIABLE is the Saved version of the Variable I want to reset)

 

IF $PAGEID = 1 THEN

BEGIN

%ZZHEALTH := %HEALTH

%ZZAGE := %AGE

%ZZFRIENDS := %FRIENDS

%ZZENEMIES := %ENEMIES

%ZZDRAMA := %DRAMA

%ZZGOLD := %GOLD

END

IF $PAGEID = 200 THEN

BEGIN

%ZZHEALTH := %HEALTH

%ZZAGE := %AGE

%ZZFRIENDS := %FRIENDS

%ZZENEMIES := %ENEMIES

%ZZDRAMA := %DRAMA

%ZZGOLD := %GOLD

END

IF $PAGEID = 300 THEN

BEGIN

%ZZHEALTH := %HEALTH

%ZZAGE := %AGE

%ZZFRIENDS := %FRIENDS

%ZZENEMIES := %ENEMIES

%ZZDRAMA := %DRAMA

%ZZGOLD := %GOLD

END

IF $PAGEID = 400 THEN

BEGIN

%ZZHEALTH := %HEALTH

%ZZAGE := %AGE

%ZZFRIENDS := %FRIENDS

%ZZENEMIES := %ENEMIES

%ZZDRAMA := %DRAMA

%ZZGOLD := %GOLD

END

 

Then with that in place, I use a Link Script on my Reset Chapter Pages: NOTE – do not use a RESET GAME LINK – Use a Standard Link to the Page or by $DEST := @PXX (as a RESET GAME link will reset the ZZVARIABLE to 0, while a Standard Link will retain the Value).

 

%HEALTH := %ZZHEALTH

%AGE := %ZZAGE

%FRIENDS := %ZZFRIENDS

%ENEMIES := %ZZENEMIES

%DRAMA := %ZZDRAMA

%GOLD := %ZZGOLD

 

This should work for Links in the Current Chapter back to the Beginning of the Current Chapter. Links back to Previous Chapters are also possible, but each would require its own set of Save Variables in the Global Script.

 

For Example:

 

IF $PAGEID = 1 THEN

BEGIN

%C1HEALTH := %HEALTH

%C1AGE := %AGE

%C1FRIENDS := %FRIENDS

%C1ENEMIES := %ENEMIES

%C1DRAMA := %DRAMA

%C1GOLD := %GOLD

END

IF $PAGEID = 200 THEN

BEGIN

%C2HEALTH := %HEALTH

%C2AGE := %AGE

%C2FRIENDS := %FRIENDS

%C2ENEMIES := %ENEMIES

%C2DRAMA := %DRAMA

%C2GOLD := %GOLD

END

IF $PAGEID = 300 THEN

BEGIN

%C3HEALTH := %HEALTH

%C3AGE := %AGE

%C3FRIENDS := %FRIENDS

%C3ENEMIES := %ENEMIES

%C3DRAMA := %DRAMA

%C3GOLD := %GOLD

END

IF $PAGEID = 400 THEN

BEGIN

%C4HEALTH := %HEALTH

%C4AGE := %AGE

%C4FRIENDS := %FRIENDS

%C4ENEMIES := %ENEMIES

%C4DRAMA := %DRAMA

%C4GOLD := %GOLD

END

 

"Restarting" chapters and variables

12 years ago

Wow that is fantastic. I think I understand it. 

I'm going to bookmark this and attempt it once I'm done with the game. That way I'll have all the variables and possible endings done. Thank you so much!