Please or Register to create posts and topics.

Custom key binding: trigger a relay

Hello;

In a level I'm currently working on I want to use a custom key binding.
Basically when someone presses [Shift] something should happen (this is done by a relay) and when the key is released the undo-relay should be triggered. Is there any way I can do this?

Would a point_clientcommand help ? With a logic_auto output that has OnMapSpawn;"point_clientcommand"; bind <shiftkey> env_fire_relay_xxx or something like that ?

I think the point_clientcommand can be used to input something into the console as if the player had written into the console themselves, so rather then have each player do this you can automate it for them, then tell them somehow (via in-game text/speech or in the download notes/readme) that this has been set up for them...

I'm not sure how/if it notices that the key has been released though, but I'm sure this is the right track to solving this ...

See here and
here for more information and I think you will get what I'm hinting at trying ... ..

lpfreaky90 wrote:
Hello;

In a level I'm currently working on I want to use a custom key binding.
Basically when someone presses [Shift] something should happen (this is done by a relay) and when the key is released the undo-relay should be triggered. Is there any way I can do this?

First, you need to make a cfg file. Those manage the custom key bindings (make a backup first).
Then, add your key binding
bind "SHIFT" "ent_fire logic_relay trigger".
Then in your map, map a logic_auto and add this output
OnMapSpawn - @command - exec yourconfigname
And when you reach the end of your map, add the trigger
OnTrigger - @command - exec config_default
Remember to do the last output, since steam cloud will upload your key bindings and it will be like that forever until you reset the config file

This would stuff with custom key bindings though.

Image
I think in terms of boolean variables. Generally, it makes things easier.

cheers! thanks for the reactions; totally gonna try this :D

Be sure to also have a look at the game_ui entity. I haven't experimented with it myself, but it looks like it was made for the exact thing that you want to do.

Sendificate series: Sendificate | A Beam Too Far | Airtime | 302
Other Portal 2 maps: Medusa Glare
Portal 1 maps: Try Anything Twice | Manic Mechanic
HMW wrote:
Be sure to also have a look at the game_ui entity. I haven't experimented with it myself, but it looks like it was made for the exact thing that you want to do.

Cheers; this could be helpful! I was actually thinking about using a tiny bit of gravity tricks in my map. The plan was to hold an object. But this could let the player get stuck in a gazillion ways.

New question: do you think holding Space this can be done with game_ui will that lowers the gravity will do? So basically longer space jump -> longer jump? Or would it be too confusing?

A game_ui tracks the player's commands and fires outputs based on the basic movements and buttons pressed by the player.

Since SHIFT is not a defaulted binded key, a gameui would do nothing, however if someone binded shift to use or something the gameui's OnPressedUse will activate if the correct output is placed.

I would suggest binding and setting aliases for your custom key.

Code: Select all
alias customthing "ent_fire relayname trigger"
bind SHIFT customthing
lpfreaky90 wrote:
New question: do you think holding Space this can be done with game_ui will that lowers the gravity will do? So basically longer space jump -> longer jump? Or would it be too confusing?

Holding down a key will not activate the ui more than once, however you can make something activate using a ui and continue activating (whether you use a timer or something else) and then when you 'UnPress' the button it stops the action.

If you want to make the palyer jump higher, I would stay away from changing gravity and use a point_push or trigger_push parented to the player which pushes the player upwards (is activated when you press jump and deactivated when you unpress it)

To stop the player from flying in the air from holding space, I would force the player to finish jumping using the command '-jump' or make it automatically deactivate after a few seconds and can make it 'activatable' once again when you are on the ground (triggers?).

?????????????????????????????TWP Releases | My Workshop
chickenmobile wrote:
A game_ui tracks the player's commands and fires outputs based on the basic movements and buttons pressed by the player.

Since SHIFT is not a defaulted binded key, a gameui would do nothing, however if someone binded shift to use or something the gameui's OnPressedUse will activate if the correct output is placed.

I would suggest binding and setting aliases for your custom key.

Code: Select all
alias customthing "ent_fire relayname trigger"
bind SHIFT customthing
lpfreaky90 wrote:
New question: do you think holding Space this can be done with game_ui will that lowers the gravity will do? So basically longer space jump -> longer jump? Or would it be too confusing?

Holding down a key will not activate the ui more than once, however you can make something activate using a ui and continue activating (whether you use a timer or something else) and then when you 'UnPress' the button it stops the action.

If you want to make the palyer jump higher, I would stay away from changing gravity and use a point_push or trigger_push which pushes the player upwards (is activated when you press jump and deactivated when you unpress it)

To stop the player from flyign in the air from holding space, I would force the player to finish jumping using the command '-jump' or make it automatically deactivate after a few seconds and can make it 'activatable' once again when you are on the ground (triggers?).

Cheers! That's a lot easier!