Page 1 of 1

ChangeVariableAction

PostPosted: Thu Jan 26, 2006 9:48 am
by DilloDude
I would like to have an action that is activated when a variable is changed,
for example:
Code: Select all
on ChangeVariable(health, decrease, any amount)>play a sound
. First value is the variable, then how it is changed (deacrease, increase, increase or decrease, set to), then by how much (any amount, 1, 2,etc.). This would be good as in the above example, to play a sound or animation when the health is decreased, and would probably be useful for other things. You could also set it to different amounts, so if the health variable is decreased by 1-5 it plays one sound, from 6-10 another and so on.

PostPosted: Thu Jan 26, 2006 1:39 pm
by marathon332
I second that request.

Having a variable update feature would make things more event driven and reduce the need to monitor variables with the draw actor event.

That should reduce the processor load, shouldn't it?

--Steve

PostPosted: Thu Jan 26, 2006 1:54 pm
by Kodo
But changing a variable and triggering an even is such an easy thing to do anyway. Say take health from your player character after it gets hit by a bullet you have to test for the collision, so why not just reduce the health and play the sound there, or call a subroutine that handles the event. If you were to put this new function in the global code it would need to check whether or not the relevant variable has changed on every frame instead of only when theres a collision between 2 objects, which would make the cpu load worse, wouldnt it?

PostPosted: Thu Jan 26, 2006 8:43 pm
by Game A Gogo
i tink the feature that dilo dude is asking is already implent.

just to this
ex:
Code: Select all
if ( [your variable] == [The number or phrase that you want wwhen the action will be activated])
{
      [the action taken]
}


if this is not what your looking for, sorry.

PostPosted: Thu Jan 26, 2006 9:03 pm
by DilloDude
Game a Gogo wrote:
Code: Select all
if ( [your variable] == [The number or phrase that you want wwhen the action will be activated])
{
      [the action taken]
}


Sounds good, I might try that!

PostPosted: Thu Jan 26, 2006 9:20 pm
by DilloDude
I got it working using an if statement in the health display's draw actor. I have it so it is activated before the textNumber is updated, so now my draw actor for Health looks like this:
Code: Select all
if (health > 100)
{
    health=100;//the health should not get greater than 100
}
if (health<0)
{
    MoveTo("Nindill", savx, savy, 5000.000000, "Game Center");
    health=100;// have an action when health is less than 0
}
if (health<textNumber)
{
    //have an action when you get hurt.(no acton yet)
}
textNumber=health;