Howdy, Stranger!

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

Change Two Stat at Once

Hi there. I am not sure if this had been ask or not. But I can't find anything about it.
So, my question is, is it possible to change two variables at once instead of set them manually in every passage?
E.g. if the player choose "help to fight off a demon", add 1 to honor and minus 1 to infamous.
Basically it is like, if put +1 into $honor, then - 1 into $infamous
Obviously, the I can't code like above.

Comments

  • edited November 2016
    What story format are you using?

    While you answer, I'll give you an example for Harlowe.
    This is from one of my stories, the player can pick three options: Mage, Rogue, or Warrior.
    As you can see I set different variables based on the player's selection: class, hit points, and content of the inventory.
    [Mage]<mage| 
    
    [Rogue]<rogue| 
    
    [Warrior]<warrior| 
    
    {(click: ?mage)[(set: $class to "Mage")(set: $hp to 6)(set: $inv to $inv + (a: "spellbook", "cloth armor"))(goto: "Town square")]
    (click: ?rogue)[(set: $class to "Rogue")(set: $hp to 8)(set: $inv to $inv + (a: "thieves tools", "leather armor"))(goto: "Town square")]
    (click: ?warrior)[(set: $class to "Warrior")(set: $hp to 10)(set: $inv to $inv + (a: "sword", "chain mail armor"))(goto: "Town square")]}
    

    I hope this helps
  • Melyanna wrote: »
    What story format are you using?

    While you answer, I'll give you an example for Harlowe.
    This is from one of my stories, the player can pick three options: Mage, Rogue, or Warrior.
    As you can see I set different variables based on the player's selection: class, hit points, and content of the inventory.
    [Mage]<mage| 
    
    [Rogue]<rogue| 
    
    [Warrior]<warrior| 
    
    {(click: ?mage)[(set: $class to "Mage")(set: $hp to 6)(set: $inv to $inv + (a: "spellbook", "cloth armor"))(goto: "Town square")]
    (click: ?rogue)[(set: $class to "Rogue")(set: $hp to 8)(set: $inv to $inv + (a: "thieves tools", "leather armor"))(goto: "Town square")]
    (click: ?warrior)[(set: $class to "Warrior")(set: $hp to 10)(set: $inv to $inv + (a: "sword", "chain mail armor"))(goto: "Town square")]}
    

    I hope this helps
    Thank for replying.
    I am using Harlowe as well.
    Maybe my question is not clear enough.
    Let's say I have (set: $honor to 5), (set: $infamous to 5)
    I want the variable will +1 into honor and -1 into infamous at the same time, like, whenever honor +1, infamous will get -1
    So there is a passage and the player can choose "kill it" or "spare it"
    And let's say the player choose "spare it", I will only need to code (set: $honor = $honor +1). And the $infamous will get -1 as well without coding.
  • The easiest solution I could think off would be to add a recalculation to your system.

    F.e. you have your stats in the header, say "honor: 5, infamous 3".

    And you may add a variable $honorchange. When you decide to "spare":

    (set: $honorchange to 1)

    And when your header would recalculate the values for $honor and $infamous on page change:

    (if: $honorchange is not 0)[
    (set: $honor to it + 1)
    (set: $infamous to it - 1)
    (set: $honorchange to 0)]


    Also you could use the (display:) macro to execute some series of commands previously written on another passage.

  • edited November 2016
    I think the easiest way to do this (assuming that $honor and $infamous are always in opposition) would just be to (set: $infamous to (10 - $honor)) when you need to check it, and ignore it the rest of the time. That way, infamous is determined entirely in terms of honor-- in fact, you could even dispense with the variable name entirely, and just use (10 - $honor) whenever you want to check it.
Sign In or Register to comment.