Ok all. here's the situation. I am creating a game in which a guy is burning from the inside. I have it set to timer 1 with setTimer(1,40)
in GlobalScript.asc
---------------------------------------------------
function repeatedly_execute()
{
if (IsTimerExpired(1)==1)
{
heatUp();
SetTimer(1, 100);
}
}
That function works fine. I have a water bottle that currently lowers the character's heat value by a defined value. That also works. I am now trying to pause the heatUp() function for 60 seconds after using the water bottle, then continue. I have tried to create my own timer to decrament in a while loop for the pause, but it doesn't seem to work.
function iWaterBtl_Interact()
{
coolOff(); // cools off player and designated amount
waterToken -= 1; // decrements waterToken by 1, starting at 4 (declared in global variables)
if (waterToken ==0) // if waterToken reaches 0, remove iWaterBtl from inventory
{
cChristian.LoseInventory(iWaterBtl);
}
mouse.Mode=eModeInteract;
while (waterTimer >= 0) // water timer declared in global variables as int 60
{ // while waterTimer is greater than 0
heatIndex = heatIndex; // set heatIndex to itself (aka.. pause heatIndex)
waterTimer -= 1; // decrement waterTimer by 1
}
}
You'll need to set another timer with iWaterBtl_Interact() and check it in repeatedly_execute(). If the first timer has expired, check if the second timer has expired, then perform the heatUp(), otherwise don't do anything.
bool waterTimerEnabled;
function repeatedly_execute()
{
if (IsTimerExpired(1))
{
if (!waterTimerEnabled || (waterTimerEnabled && IsTimerExpired(2))) {
heatUp();
SetTimer(1, 100);
waterTimerEnabled = false;
}
}
}
//[...]
function iWaterBtl_Interact()
{
coolOff();
waterToken--;
if (waterToken == 0) cChristian.LoseInventory(iWaterBtl);
mouse.Mode = eModeInteract;
waterTimerEnabled = true;
SetTimer(2,2400);
}
Thanks for the response. What you gave me definitely stopped the heatUp() function, but wouldn't continue it. I finally figured out what it was.
function repeatedly_execute()
{
if (IsTimerExpired(1))
{
if (!waterTimerEnabled || (waterTimerEnabled && IsTimerExpired(2))) {
heatUp();
SetTimer(1, 80);
waterTimerEnabled = false;
}
SetTimer(1, 80); <-- Needed this to continue original timer.
}
}
Ah right, sorry about that. Glad you got it working.