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:

SirIncompetent

The unfunny terrible person!
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 :(
 

Rapidgame7

scripting bee
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"
 

Goldenhog

Wandering Protagonist
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
 

Rapidgame7

scripting bee
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:

Goldenhog

Wandering Protagonist
mQrTKWr.gif


Works without a hitch. Now I can play Dicky Nicky without feeling like my eyes turned into binoculars!
 

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

Top