ID:1516340
 
(See the best response by JEY_SENSEY.)
Code:
//Base Code
obj/var/list/cooldowns = list()

obj/proc/cooldown()
for(var/v in cooldowns)
if(world.time == cooldowns[v])
cooldowns[v] = 5

//Where its implemented
/skills/Regen
var
cooldown
icon_state="regen"
DblClick()
if(cooldowns["Regen"])
usr<<"You can't use Regen yet!"
return
else
usr<<"You used Regen!"
if(usr.health <= usr.max_health)
usr.health += usr.max_health - usr.health
cooldowns["Regen"] = world.time + cooldown


Problem description:
When i run it i dont get any runtime errors, but when i use it the cooldown never runs out and i cant use the skill anymore.

Best response
I'm not sure but I think you should define a number in
/skills/Regen
var
cooldown=5//example

is only a hypothesis if not im so sorry and help from another user:-s
Yeah its not that either i dont think :S I tried that and it persisted so yeah :/
Take a look at the following line:
if(cooldowns["Regen"])


This says, if I have a list element called Regen, I am not cooled down.

Here, you create it:
cooldowns["Regen"] = world.time + cooldown


This is never removed, so the if(cooldowns["Regen"]) never evaluates false after the first time. What you want to do is make a comparison vs. current time.

if(cooldowns["Regen"] && cooldowns["Regen"] >= world.time)
//this says, if the element exist AND it is greater than the current time


Now, as /skills is some form of datum, you'll only be modifying one value cooldowns ever, right? It's needless to be a list.

I don't understand what the base code is really meant to do for you here...it really doesn't do anything impressive.