So how does cooldown work?

How, what and why to code in BYOND.

Moderators: MisterPerson, Giacom, Nienhaus, Code Maintainers

Joined: Tue Jul 10, 2018 2:35 pm
Location: Russia
Byond Username: ClickerOfThings
Github Username: ClickerOfThings

So how does cooldown work?

Unread postby ClickerOfThings » Tue Jul 10, 2018 2:54 pm #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
Github User
Joined: Sun Jul 24, 2016 3:45 pm
Byond Username: Pubby
Github Username: pubby

Re: So how does cooldown work?

Unread postby pubby » Tue Jul 10, 2018 9:35 pm #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
Code Maintainer
Joined: Tue Apr 15, 2014 9:16 pm
Byond Username: Optimumtact
Github Username: optimumtact

Re: So how does cooldown work?

Unread postby oranges » Wed Jul 11, 2018 2:20 am #425323

don't help people who are writing macros pubby

Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest