Howdy, Stranger!

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

Deducting variables from other variables.

To create a combat system I want to be able to have both the opponents agility stat and the player's agility stat influence the hit chance. What I tried was deducting them from eachother in this manner
<<set $hitchance to $Agility - $OppAgility>>

However that doesn't seem to work. Is it possible at all to deduct one variable from another?

Comments

  • Hi Sytze,

    generally speaking it is better to mention Twine version and story format you are using when asking such a question, it will help others to get a clue of what may go wrong in your particular case.
    Also consider pasting the passage 'code' so that we clearly understand what you want to achieve and how you use variables.

    That being said, I think your syntax is correct, I just tested on Twine 1.4 with Jonah and SugarCube and it works, maybe try the following:
    - ensure $Agility & $OppAgility are properly set before doing the calculation
    you can check their values using <<print $variable_name>>
    - maybe try <<set $hitchance to ($Agility - $OppAgility)>>

    Please consider giving more details if ever you still get stuck ;)
  • Thanks a lot Aniki,

    I did what you said and it was a problem of one of the variables not being set properly (due to a capital letter somewhere which was missing somewhere else).
Sign In or Register to comment.