I have some code that uses objects to determine how far along you are. The basic gist is that the room has 3 tracks with 2 pieces each, and the progress is printed when you look.
The code below works. The commented-out “volume this doesn’t work” part does not, and I don’t understand why.
"Game Progress" by Andrew Schultz
volume basics
a progress-track is a kind of thing. a progress-track has a number called this-progress.
t1 is a progress-track.
t2 is a progress-track.
t3 is a progress-track.
r1 is a room. "You've made no progress with [list of undone progress-tracks]. You've made progress with [list of halfdone progress-tracks]. You've dealt with [list of alldone progress-tracks]."
volume this works
definition: a progress-track (called x) is undone:
if this-progress of x is 0, yes;
no;
definition: a progress-track (called x) is halfdone:
if this-progress of x is 1, yes;
no;
definition: a progress-track (called x) is alldone:
if this-progress of x is 2, yes;
no;
volume this doesn't work
[r1 is a room. "You've made no progress with [the-track of 0]. You've made progress with [the-track of 1]. You've dealt with [the-track of 2]."
to say the-track of (n - a number):
say "[list of progress-tracks with this-progress of n]"]
volume testing stubs
to bump-up (pt - a progress-track):
if this-progress of pt is 2:
say "[pt] is at its max.";
else:
say "Bumping up [pt].";
increment this-progress of pt;
every turn: bump-up a random progress-track;
I’m okay with this, but the 3 definitions are certainly awkward. The commented code feels like it should work, but it doesn’t compile.
Is there a way to generalize the code so I don’t have to use the 3 definitions?
actual source from my EctoComp Petite Mort game, a slightly different way
a rowr-mood is a kind of thing.
a rowr-mood can be unactivated, halfway or fullon. a rowr-mood is usually unactivated.
Rowr Room is east of Rare Rows. printed name is "[if rowr-progress-score < 3]Rowr Room[else]Bower (BOOM!)[end if]". win-score of rowr room is 3. "[if number of unactivated rowr-moods > 0]It's very noisy here. To dissipate the that, perhaps you could [list of unactivated rowr-moods]. [end if][if number of halfway rowr-moods > 0]You also have notions of [list of halfway rowr-moods], but just for fun. [end if][if number of fullon rowr-moods > 0]You have exhausted the ways to [list of fullon rowr-moods]. [end if]The only way out is back west.". block-descrip-text of Rowr Room is "it's too hot to the east"
tomb-womb is a rowr-mood. printed name of tomb-womb is "create a secret passage you'll never explore".
flume-plume is a rowr-mood. printed name of flume-plume is "create some fireworks".
doom-gloom is a rowr-mood. printed name of doom-gloom is "change the mood".
[this is a slightly awkard function, just as definitions are]
to bump-up (moo - a rowr-mood):
if moo is unactivated:
now moo is halfway;
else if moo is halfway:
now moo is fullon;
else:
say "BUG. I tried to increase a mood that was already maximized. Let me know how this happened!"
Note that this is with 6G, as I’m having problems compiling with later versions–I have 6G projects, so I use the 6G IDE, and I installed Inform 10.1.2 which got in the way of testing on my 6M IDE.