Forum rules - please read before posting.

Variable issue in 1.30

edited April 2014 in Technical Q&A
I love the new formula feature for setting variables, but there is one issue I have encountered. I have a battle scene where the player attacks an enemy, and if the attack hits, the enemy's health value is supposed to decrease by the player's attack value.

Before 1.30, I just used placeholder numbers and used the action variable : set with the increase by method to increase the enemyhealth variable by -5, or what have you. This worked fine.

Now, I'm trying to incorporate the attack variable into this formula. My action is now variable : set, the variable is enemyhealth, and the method is formula, since I can't type a formula in the "increase by value" field. So assuming enemyhealth is [var:1] and attack is [var:2], I have the formula set up as enemyhealth = [var:1] - [var:2].

This action works fine the first time it is used. So lets say I have initially set the enemyhealth variable to 20 in the variables manager, and attack is set at 5. When the action is first run, I followed the variable's value in the persistent engine inspector and the enemyhealth variable drops to 15, as expected. 

However, when it is run a second time, the value will stay at 15. Nowhere in this scene does the enemyhealth variable get reset, so I have no idea why it isn't working the same way when run after the first time. My only conclusion is that when the variable : set action is run the second time, the [var:1] token is understood to mean the initial enemyhealth value, and not the enemyhealth value that was changed after the action was run the first time.

Is that the problem? Anyone know of a way to fix this problem? Thanks!

Edit: Apparently this also happens when trying to set variables as formulas in menu/inv actionlists too. Even further, after the action has been run once, the variable token (i.e. [var:1]) will be replaced with the value of the variable obtained at that time. This shows up in the inspector as the number instead of the token, even after the game has been stopped. 

Comments

  • I will investigate.  Where exactly is the token being replaced?  In the forumla box itself?
  • In the formula box, and also in the inspector for each individual action in an inv/menu actionlist. It looks like even though the token is replaced in those, the formula does still work as it should the first time it is run.

    So even though [var:1] is replaced by 15 in the inspector, say, if I run the game again afterwards and add 1 to that variable in the game, it will change to 16 in the inspector.
  • Fixed for 1.31
  • Awesome, thanks!
Sign In or Register to comment.

Howdy, Stranger!

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

Welcome to the official forum for Adventure Creator.