So how does cooldown work?

How, what and why to code in BYOND.
Post Reply
ClickerOfThings
Joined: Tue Jul 10, 2018 2:35 pm
Byond Username: ClickerOfThings
Github Username: ClickerOfThings
Location: Russia

So how does cooldown work?

Post by ClickerOfThings » #425233

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.
User avatar
pubby
Github User
Joined: Sun Jul 24, 2016 3:45 pm
Byond Username: Pubby
Github Username: pubby

Re: So how does cooldown work?

Post by pubby » #425286

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)
User avatar
oranges
Code Maintainer
Joined: Tue Apr 15, 2014 9:16 pm
Byond Username: Optimumtact
Github Username: optimumtact
Location: #CHATSHITGETBANGED

Re: So how does cooldown work?

Post by oranges » #425323

don't help people who are writing macros pubby
Post Reply

Who is online

Users browsing this forum: No registered users