Author Topic: Energy bar decay  (Read 1096 times)

How would I make it so a player's energy bar decays at a steady rate and when it's empty it calls a function?




You cannot without a schedule

You need to make a seperate function for a loop (this is mandatory), and from Armor::onAdd( %this, %obj ) function (call parent, put in package. Howto here) call the loop.

In the loop, check if player is alive. If not, return; .
Also check the energy level. If it's <= 0, call function then return; (unless you want your function to be called at a constant rate)

If you don't know how to make a loop, here's how it should look like:
Code: [Select]
function player::yourLoop( %this )
{
cancel( %this.yourLoop );

code here

%this.yourLoop = %this.schedule( XX time in ms, FUNCTION NAME (put "yourLoop" in here you derp) );
}

I set the datablock's recharge rate to -0.3. Works how I want it to now. Locking.

I set the datablock's recharge rate to -0.3. Works how I want it to now. Locking.

Don't lock topics here.