proc/Countdown()
var/seconds = timer%60
var/minutes = round(seconds/60)
while(seconds > 0 || minutes > 0)
while(seconds > 0)
seconds--
worldWinset("timer","text=\"[minutes]:[seconds < 10 ? "0[seconds]" : "[seconds]"]\"")
sleep(10)
minutes--
seconds=60
worldWinset("timer","text=\"[minutes]:[seconds < 10 ? "0[seconds]" : "[seconds]"]\"")
worldWinset is a proc that loops through all of the mobs in the world and uses winset on them.
proc/worldWinset(control, parameter)
for(var/mob/m in world) if(m.client)
winset(m, control, parameter)
[Edit]- One less while() loop, substituted by the use of % and one division. (Thanks to Vermolius)
Just saw your edit... and unfortunately, the minutes var part is wrong. seconds will only have a result of 0-59 so really you are making minutes always 0. See how I was able to make minutes a whole number without round() and avoiding that problem
The modulus procedure is very helpful for this type of thing:
Essentially what the above has done is obtain how many seconds has passed (see the modulus (%) entry in the DM reference) and subtract that from the timer (so timer has all minute based values) and divided that by 60
For example: Lets say timer is 125 (2 min 5 sec).
seconds = 5 (125%60 = 5)
minutes = 2 ( (125-5)/60 = 120/60 = 2)
That takes of your first while() there.
In reality, the above snippet really didn't do anything much as the first snippet... so you can disregard this one if you wish.
For your second snippet, you can loop for all clients instead and winset() that client (you can use either the /mob or the /client as the first argument):