ID:924097
 
Keywords: button, speed
Code:Run button
Button
Run
name = "Run"
icon_state = "button-run"
animation = "run"
cooldown = 0


I'm new here and i try to learn ty. Ok, so i have this button and a var
mob
var
base_speed = 3
, what i want is when i press this button base_speed change to 8 and when the button isnt press base_speed change back at 3 . Some help ?

Modify the Button/Run/Click() proc to determine what the user's current base_speed is and change it according to.

usr.base_speed = usr.base_speed == 3 ? 8 : 3
In response to Boubi
i'm new didint know how to do it :-? tryed 10 times :)))

BUT

i tryed for 3 days to do it and dunno how, after i read your post 15 times i had an ideea with sleep(), and WORKED ! THX mate !

Button
Run
name = "Run"
icon_state = "button-run"
animation = "run"
makeit(mob/user)
if(user.base_speed == 3)
user.base_speed = 8
sleep(1.5)
user.base_speed = 3
return
Your sleep(1.5) would only round either up or down, I forgot on my part, unless you've changed the world.tick_lag. I don't know how makeit(mob/user) is called, but what you're doing in the proc is practically pointless, if you think about it. This would only work for 1.5 seconds, unless that's how you want it to be.

This is what I meant when I posted what I posted:

Button/Run
name = "Run"
icon_state = "button-run"
animation = "run"
// when i said modify Click(), this is what i meant
Click()
// click is a built-in proc
usr.base_speed = usr.base_speed == 3 ? 8 : 3
world << usr.base_speed
// ^-- translates to if the user's base speed is 3 change it to 8, else do the opposite
..()
In response to Boubi
"This would only work for 1.5 seconds"

This is the point , cuz is a macro button for a run command , you press -> you run(even if is 1.5 seconds) / stop pressing -> you walk .

And if you press continue , the character will have basee_speed = 8 -> 1.5 + 1.5 .... ( hou much you press ) , if you stop pressing base_speed come back to 3