Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to Xbox Chaos: Modding Evolved

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
Gabotron ES

Support
How to check if a GlobalNumericX changed it's value

3 posts in this topic

So I'm trying to check if a GlobalNumeric just changed it's value on runtime, that's it if say it's value was 56 a few seconds ago but now it's 57.

 

How would that look like in KSoft?

Share this post


Link to post
Share on other sites

Let's call the global numeric that you want to track GlobalNumericX. Make another variable which we'll call GlobalNumericY, and make sure it's given the same default value as GlobalNumericX. Then, at the end of your script, make a trigger that does this (psuedocode; I don't know KSoft's syntax, sorry):

 

If GlobalNumericX is not equal to GlobalNumericY:    The value changed, do somethingGlobalNumericY = GlobalNumericX

 

Basically, this causes GlobalNumericY to always hold the "old" value of GlobalNumericX, so if they're different then that means it changed.

 

Of course, it might also be easier in some cases to just do whatever you need to whenever you set the variable's value. (Plus that would save a global.)

Share this post


Link to post
Share on other sites

Here's some KSoft-ey semi-pseudocode;

<Trigger>  <Branch>    <Condition Comparison>      <Param GlobalVariableX /> //main variable      <Param GlobalVariableY /> //variable to detect changes      <Param NotEqual />    </Condition>    <Action DoStuff />  </Branch>  <Action VariableOperation>    <Param GlobalVariableY />     <Param GlobalVariableX />    <Param Set />  </Action></Trigger>
If you want it to detect the change within the tick that it happens, put it at the bottom of your triggers. If you want it to detect it the tick after it changes, put it above where ever GlobalVariableX will be modified. If you want a few seconds delay, that gets a bit trickier. Edited by Gordon

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0