Greetings all! I’m having trouble figuring out how to do something. I’m trying to have a case where the player can be sent back in time. But this will mean essentially a “restart” of the game. Some dialogue, however, will indicate that they did, in fact, have a “world reset.” So I need to preserve a state that says such a reset happened.
Here’s what I’m trying. (Incredibly minimal experiment.)
!% -G
!% +include_path=../../inform6lib
Constant Story "Learning";
Constant Headline "^An Interactive Learning Example^";
Include "Parser";
Include "VerbLib";
Constant RESET 1;
Array time_travel_state -> 2;
[ Initialise;
print time_travel_state -> 1;
TimeTravelOccurred();
if (time_travel_state -> RESET == false) {
print "Time travel has not occurred.";
} else {
print "Time travel has occurred.";
}
];
[ TimeTravelOccurred;
@protect time_travel_state 1;
];
Include "Grammar";
[ MyResetSub;
time_travel_state -> RESET = true;
TimeTravelOccurred();
print time_travel_state -> 1;
];
Extend "version" replace
* -> MyReset;
end;
For this simple example, if someone types “VERSION”, I’ve set up a replace function that will set the variable in question to true. Then I have a TimeTravelOccurred state that will protect that variable.
What I’m doing definitely doesn’t work. Meaning that even if I just do a restart, nothing actually gets protected. I’m also going to clearly need this to persist across save/restore, but if my small experiment on restart isn’t workable, there’s probably not much point in complicating the example.
Does what I’m doing here seem logical at all?