How do you tie a command to a button?

Please don't respond with code, I'm can't make mods. If someone is kind enough to make a addon, please make it compatible with other addons.
 
Last edited:
To perform what you want, use the bind <key> <commands> console command.
bind takes two arguments: The key to bind the action to, and the whole console input to run when it is pressed.

For example, if I wanted to change my color to blue and my skin to Sonic everytime I hit the P button, I would run this in my console:
Code:
bind p "color blue; skin sonic"


More info: https://wiki.srb2.org/wiki/Console/Commands#bind_.5B.3Ckey.3E.5D_.5B.3Ccommand.3E.5D
 
To perform what you want, use the bind <key> <commands> console command.
bind takes two arguments: The key to bind the action to, and the whole console input to run when it is pressed.

For example, if I wanted to change my color to blue and my skin to Sonic everytime I hit the P button, I would run this in my console:
Code:
bind p "color blue; skin sonic"


More info: https://wiki.srb2.org/wiki/Console/Commands#bind_.5B.3Ckey.3E.5D_.5B.3Ccommand.3E.5D

I actually never knew this was a thing! Thanks for the helpful piece of knowledge.
 
I... guess I can ask this question since it's related, Remember Admintools. lua? It has the "Goto" command, for example:"Goto Sonic"And it goes where the player named sonic is, now... How I can bind that? I put "Bind T Goto" and it tells me I have to put the player's name, then I did:"Bind t Goto sonic" and nothing happens :(
 
Enclose the console input in quotes when using bind, otherwise the game will think you're entering more than 2 arguments and say "no, that's wrong".
Code:
bind t "goto sonic"
 
Might as well chime in since my question is also related. Is it possible to have a bind that alternates between two sets of commands? So that I could press C and it runs
Code:
chasecam 0
fov 106
but if I press it again it instead does
Code:
chasecam 1
fov 90
 
Is it possible to have a bind that alternates between two sets of commands? [...]

To answer that, we need to talk about parallel universes.

First create two aliases for your camera options.
Code:
alias _cam1 "chasecam 0; fov 106"
alias _cam2 "chasecam 1; fov 90"

Then create two aliases that execute the respective camera setting and then rebind the key to the other setting.
Code:
alias _camsw1 "_cam1; bind c _camsw2"
alias _camsw2 "_cam2; bind c _camsw1"

Finally, put it all together by binding the key to one of them.
Code:
bind c _camsw1


Basically,
Code:
alias _cam1 "chasecam 0; fov 106"
alias _cam2 "chasecam 1; fov 90"

alias _camsw1 "_cam1; bind c _camsw2"
alias _camsw2 "_cam2; bind c _camsw1"

bind c _camsw1


Or, shorten it. Ugly, but if you want things compact and you don't mind having to realias the entire line if you change your mind,
Code:
alias _cam1 "chasecam 0; fov 106; bind c _cam2"
alias _cam2 "chasecam 1; fov 9; bind c _cam1"

bind c _cam1
 
Last edited:
mQrTKWr.gif


Works without a hitch. Now I can play Dicky Nicky without feeling like my eyes turned into binoculars!
 
To perform what you want, use the bind <key> <commands> console command.
bind takes two arguments: The key to bind the action to, and the whole console input to run when it is pressed.

For example, if I wanted to change my color to blue and my skin to Sonic everytime I hit the P button, I would run this in my console:
Code:
bind p "color blue; skin sonic"


More info: https://wiki.srb2.org/wiki/Console/Commands#bind_.5B.3Ckey.3E.5D_.5B.3Ccommand.3E.5D
Can I use char abilitys for example bind z "charability 1 6; skin cinos"
 
Can I use char abilitys
Depends what do you mean by "use char abilitys".
If you mean like casting character abilities, like making Sonic perform their thok, then no.

If you mean changing the player's ability with charability and then changing their skin (which changes the player's ability once more), like you are doing with your example, then yes.
 
Depends what do you mean by "use char abilitys".
If you mean like casting character abilities, like making Sonic perform their thok, then no.

If you mean changing the player's ability with charability and then changing their skin (which changes the player's ability once more), like you are doing with your example, then yes.
So I can have CA_HOMINGTHOK in my S_SKIN and put CA_DOUBLEJUMP in my lua using that lua?
 
alright so i put
bind 0 "color cornflower;skin juniosonic"
and when i press 0 it doesnt work
Post automatically merged:

ughhhh devmode 1 has to be enabled and that doesnt work well with autoexec
 
Last edited:

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top