Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Remove options from an Either macro if they are true.

So, I have set a variable called $randomPassage to one of six passages (listed below). Each passage below is associated with a quest line. I have another boolean variable for each quest (e.g. $squirrelComplete) to designate whether or not a quest line has been completed. Once the quest line is completed I would like to remove the passage from the either macro... but I'm at a loss for ideas... any ideas would be mucha appreciated!

(set: $randomPassage to (either:"squirrel","BoynRock","SnowLeopard","MountPerson","MountGoat","Pinetree"))

Comments

  • I'll hazard a guess for one way..
    You'd make a function that returns string values if your boolean quest line completed variables are true. then assign either() to that function.

    Either:function(q1,q2,q3,etc)

    I don't know the syntax to do this however.
  • You don't state which Story Format (name and version) you are using, based on the syntax of your example I will assume you are using Harlowe.

    note: My example assumes that you are setting up boolean variables like the following somewhere in your story.
    (set: $squirrelComplete to false)
    (set: $SnowLeopardComplete to false)
    

    You can use an array and (if:) macros to build the list of options that the (either) macro will choose from.
    (set: $options to (array:))
    
    (if: not $squirrelComplete)[
    	(set: $options to it + (array: "squirrel"))
    ]
    (if: not $SnowLeopardComplete)[
    	(set: $options to it + (array: "SnowLeopard"))
    ]
    
    ... you can then use special ... operateor documented in the Array Data of the manual to use the $options array with the (either:) macro.
    (set: $randomPassage to (either: ...$options))
    
  • I would go about this the reverse way. First initialise a list that will contain all the available quests, initially empty:
    (set: $availableQuests to (a:)) 
    

    Then, go through all your booleans in turn and add the corresponding quest to the list:
    (if: $squirrelComplete is false)[(set: $availableQuests to it+(a:"squirrel"))]
    

    Any quest that you've done already will not get added to the list. When you're done, just select randomly:
    (set: $randomPassage to (either:...$availableQuests))
    

  • Thanks for everyone's input, and yes I was using the latest version of Harlowe. I actually ended up doing something similar to @thebigh ... but in reverse and did the following:


    (set: $randomMountPassage to (a: "squirrel","BoynRock","SnowLeopard","MountPerson","MountGoat","Pinetree"))
    (if: $squirrelQuest is true )[(set: $randomMountPassage to it - (a: "squirrel"))]
    (if: $snowLeopardQuest is true )[(set: $randomMountPassage to it - (a: "SnowLeopard"))]
    (if: $parkRangerQuest is true )[(set: $randomMountPassage to it - (a: "MountPerson"))]
    (if: $mountainGoatQuest is true )[(set: $randomMountPassage to it - (a: "MountGoat"))]
    (if: $pineTreeQuest is true)[(set: $randomMountPassage to it - (a: "Pinetree"))]
    (if: $boyRockQuest is true )[(set: $randomMountPassage to it - (a: "BoynRock"))]
Sign In or Register to comment.