Hello everyone
Im making a game which needs to show a timer in a GUI.
I know how to set the timer, I know how to give orders when the timer expires, but I don't know how to show it in a GUI.
Does anybody know how to do?
Thankyou.
This is a beginners question really: in repeatedly_execute:
yourGuiLabel.Text=String.Format("%d", timer_value);
SSH, I think he's talking about the built-in timers.
There's no GetTimer function, so you need to script the timer yourself using variables if you want to access its current value.
Thankyou for answering
And how would you do that?
For example:
// main global script
int MyTimer = -1; // define timer variable, initially off
export MyTimer; // export variable for use in room scripts
function repeatedly_execute() { // gets executed every game loop
if (MyTimer > 0) { // if timer is on
MyTimer--; // decrease timer by 1 game loop
YourGuiLabel.Text = String.Format("%d", MyTimer); // display its value on your gui label
}
else if (MyTimer == 0) { // aka IsTimerExpired
// do stuff
MyTimer = -1; // turn timer off
}
}
// main script header
import int MyTimer; // import variable for use in room scripts
// some script
MyTimer = 400; // aka SetTimer; 40 game loops = 1 second