is there a way to "recalculate" a variable? I have a variable, the value of which is determined by math of some numbers and another variable. I set this variable at some moment, but want it to take effect at a later moment. The problem is, that the second variable, which influences the first variable may change between the two moments, so I would like the first variable to recalculate itself based on the updated second variable. Is this possible?
Yes. If it's worth it, I recommend you make a new action definition to set the second variable, which automatically recalculates the first variable. "Set 'My Variable'" for instance.
In case you need to know, it's New -> New Action Definition. Within the new action definition, add a parameter of variable 2's type called "Value" or something. Still in the definition, add an action that sets variable 2 = 'the "Value" parameter' and add other action(s) to recalculate your first variable. When you add this action to a trigger, you fill in the value you want to set it to, and it automatically recalculates your first variable the way you defined.
Ofcourse, you don't have to do this procedure, but it would allow you to update variable 1 and set variable 2 in one simple step if you'd anyway use the same calculation every single time.
Thanks for your reply. That's actually the main problem here, that I don't want to use the formula twice. Can a formula maybe given to the next function as a parameter? Not the value of the result of the fomula, but the formula itself?
Yeah, that was, what I wanted to do first. The problem is, it should be called from different locations with different formulae, but the one same variable (the value of which might change). But I found a workaround with
General - Wait for (Conditions), checking every 0.1 Game Time seconds
already. The function with the math now starts (creating a new thread) where the first variable is set, waits until the condition is met, which describes, that now the second variable is not 0 and and then sets the first variable. Isn't a very elegant solution of course, but works just fine for now.
Hi,
is there a way to "recalculate" a variable? I have a variable, the value of which is determined by math of some numbers and another variable. I set this variable at some moment, but want it to take effect at a later moment. The problem is, that the second variable, which influences the first variable may change between the two moments, so I would like the first variable to recalculate itself based on the updated second variable. Is this possible?
ty
Greetz, Shianky
Sure, just set the variables value again to the same term you used the first time and it will use the updated second variable.
Yes. If it's worth it, I recommend you make a new action definition to set the second variable, which automatically recalculates the first variable. "Set 'My Variable'" for instance.
In case you need to know, it's New -> New Action Definition. Within the new action definition, add a parameter of variable 2's type called "Value" or something. Still in the definition, add an action that sets variable 2 = 'the "Value" parameter' and add other action(s) to recalculate your first variable. When you add this action to a trigger, you fill in the value you want to set it to, and it automatically recalculates your first variable the way you defined.
Ofcourse, you don't have to do this procedure, but it would allow you to update variable 1 and set variable 2 in one simple step if you'd anyway use the same calculation every single time.
@HuggetSukker: Go
Thanks for your reply. That's actually the main problem here, that I don't want to use the formula twice. Can a formula maybe given to the next function as a parameter? Not the value of the result of the fomula, but the formula itself?
Yes you can add "formula" as parameter. In GUI there are Math-> Arithmetic etc
@Nerfpl: Go
I can't seem to follow. Where exactly can I set the parameter to "formula"?
what kind of formula your talking about
couldnt u just calculate the variable when u need it?
You could create a function that process thye formula and returns your deisred value. And everytime you need it, just invoke the function.
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
@Alevice: Go
Yeah, that was, what I wanted to do first. The problem is, it should be called from different locations with different formulae, but the one same variable (the value of which might change). But I found a workaround with
already. The function with the math now starts (creating a new thread) where the first variable is set, waits until the condition is met, which describes, that now the second variable is not 0 and and then sets the first variable. Isn't a very elegant solution of course, but works just fine for now.
Thanks anyway!