Page 1 of 1

So how does cooldown work?

Posted: Tue Jul 10, 2018 2:54 pm
by ClickerOfThings
I'm new to SS13 programming, and I can't understand this part of code which is taken from deck code:

Code: Select all

if(cooldown < world.time - 50)
		cards = shuffle(cards)
		playsound(src, 'sound/items/cardshuffle.ogg', 50, 1)
		user.visible_message("[user] shuffles the deck.", "<span class='notice'>You shuffle the deck.</span>")
		cooldown = world.time
Specifically I can't understand "if(cooldown < world.time - 50)" and "cooldown = world.time"
I tried to search these 2 lines in every file but I couldn't find any answer.
If someone could explain me these lines, I would appreciate that.

Re: So how does cooldown work?

Posted: Tue Jul 10, 2018 9:35 pm
by pubby
It's just an ordinary variable that's being used to measure time elapsed.

Code: Select all

cooldown = world.time
Sets the point to measure from.

Code: Select all

if(cooldown < world.time - 50)"
Checks if 50 ticks have elapsed.

(world.time is the number of ticks that have occurred, I believe)

Re: So how does cooldown work?

Posted: Wed Jul 11, 2018 2:20 am
by oranges
don't help people who are writing macros pubby