0 votes
by (120 points)

I don't have much coding experience and I'm sort-of learning as I go. I'm using Harlowe format.

The player has the option of interacting with 3 different people - Person A, Person B, and Person C. For each of those people there are 3 possible interactions - two of these interactions will fail, one will succeed. When the player fails, they end up at a passage titled, for example, "PersonAfail". This passage gives the player the option to try again with whoever is remaining (if anyone).

The bit I'm having trouble with is this. Say you interacted with Person A first, failed, ended up at the fail passage and had the option of trying again with Person B or Person C. I have a piece of text offering that option. But if you already played (and failed) Person B, then tried Person A (and failed again), you only have one option left - in which case, I have a piece of text offering the one remaining option [[Person C]]. Or vice-versa if you already tried Person C and only have Person B remaining. Plus a final piece of text if all three interactions have been attempted and failed, in which case the game is over.

I thought I could use the if: macro to alter the available options in the 'fail' passage, but I'm not sure the best way to do it. At the moment my code for "PersonAfail" reads like this:

(if: (history:) contains “Person A”)
[There are two remaining:


(elseif: (history:) contains “PersonBfail”)
[There is one remaining:


(elseif: (history:) contains “PersonCfail”)
[There is one remaining:

[[Person B]]]

[There are no people left!

[[Final passage]]]

Which obviously doesn't work, because in order to arrive at "PersonAfail" you had to pass through the "Person A" passage, which means the first hook ("There are two remaining") is always visible. So what macro do I need to use, and how, in order to alter/reduce the player's options as they play through the game?

I know I'm probably overcomplicating this.

1 Answer

0 votes
by (170 points)

what if you used

(if: (history:) contains "PersonA" and not "PersonAfail")
//also might have to try
(if: (history:) contains "PersonA" and not (history:) contains "PersonAfail")
//both should work thought

this way if you've been to both PersonA will be true but not PersonAfail will be false, making the 'and' statement false.

by (159k points)

If you are going to reference the (history:) macro multiple times within the same Passage then I suggest that you first save the Array returned by that macro in a temporary variable, and then reference that temporary variable in the Passage instead.

(set: _history to (history:))

(if: _history contains "PersonA" and not (_history contains "PersonAfail"))[]

The main reason I suggest this is because the (history:) macro has to generate/populate the Array it returns, and getting the macro to generate the same Array multiple times within the same Passage is wasteful.

by (120 points)
edited by

Thanks for the suggestion, but I still can't get it to work. I want to tell the game, 'If the player selected A they still have 2 choices left, but if they selected A and B they only have 1 choice left'. But I think the problem is that no matter what choices the player has made, they will always have to select A to reach this point, so my (elseif:) will be ignored because my (if:) is essentially always true?

The only way I can think of getting around this is maybe to make a separate parallel passage ("PersonAfail2") for the remaining 2 options? I don't know, my brain hurts too much to think straight!

EDIT: Actually, my brain just started working again and I think I found a solution. I've added a $player variable at the start of the game, set at 0, and added (link: "Person A")[(set: $player to 1)(goto: "personA")] in the PersonBfail passage, thus enabling me to (elseif: $player is 1) in the PersonAfail passage. If any of that makes any sense. But it seems to work so far...