Add a custom key/button

Avatar
gallardo
85 Posts
Posted Jan 31, 2014

Hi there,
I need to add a custom action to the game that the player would be able to bind to a button of choice.
I know how to do it if it were a mod, but this should work for a map in the workshop, i.e. I cannot overwrite existing files (right?).

the alternative is that I "hard-code" it via console command, but it isn't ideal:
1) not customizable
2) could overwrite existing options

any idea?

EDIT:
related topics

post92071.html?hilit=custom%20binding#p92071 (UNSOLVED)

post69091.html?hilit=custom%20binding#p69091 (partially solved)

Advertisement
Registered users don't see ads! Register now!
Avatar
srs bsnss
552 Posts
Posted Jan 31, 2014
Replied 32 minutes later
You could use a point_clientcommand to bind a key. You have to be careful with this kind of thing though, because you never know what binds people already have that you might over-write. But this will probably work.

Alternatively, game_ui.

Avatar
FelixGriffin
2,680 Posts
Posted Jan 31, 2014
Replied 1 hour later
Logic_playerproxy gives you jump and duck as well.
Avatar
RustyDios
154 Posts
Posted Jan 31, 2014
Replied 4 hours later
How about explaining what it does/what you want it to do and how to bind it to a key in loads of different languages in an image editor. Then spice it up a bit and make it look like an information panel/poster etc for the style of map you're creating. Converting it into a custom texture file and placing it in a "set-up" room before your main map. Make it so you can't possibly miss it and have the room exit somehow need your custom action to get out and into the main map..

Kindly asking the player to do it themselves in this kind of manner is the only option I can think of that won't mess up any previously set custom bindings by the player.

Avatar
gallardo
85 Posts
Posted Feb 01, 2014
Replied 10 hours later
hehe, I thought about the room as well, but seems so cheap
I should recreate a full keyboard with all the possible bindings, without excluding that someone playing in a cave would be glad to use "f12" instead of the default "alt".
more: I have to do it for controllers as well.

I would rather use the method suggested in the second thread I linked...

spongylover123 wrote:
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

...but what if the player exit before being able to reset the config?
I'd go for this route if I can write a config that ADD parameters, without changing the existing ones.
Also, by publishing the map in the Workshop, would the config file be included?

I'll test all the stuff above, but maybe you already know better.

Avatar
RustyDios
154 Posts
Posted Feb 01, 2014
Replied 13 minutes later
Sounds good.. but you run into the same problem using the @command>exec method, config_default will reset the key bindings to the default. If the player has set custom/personal keybinding (like "n" for noclip 1) it won't get reset... it's not part of the default config.

Good luck to finding a method that works for you. It would be interesting to know what you decide to do.

Avatar
HMW
806 Posts
Posted Feb 01, 2014
Replied 9 hours later
Would it be possible to use the existing player controls in a new way to activate the effect? For example, you could have it activate when the player double-taps the "duck" button.

(Maybe you can explain what the effect is without spoiling too much?)

Avatar
gallardo
85 Posts
Posted Feb 01, 2014
Replied 1 hour later
What if I use another action available in coop and unused in single, like "quick_ping"? I've to figure out how to do it though.

Yours is interesting too. another suitable one would be pressing attack1 and attack2 at the same time.

What do you think if I just use the "duck" button? you still crouch but also trigger the new action.
No problem while flying, just a little stutter when on ground.

the last one is easily achievable with logic_playerproxy, though I'd prefer "quick_ping"...

Avatar
FelixGriffin
2,680 Posts
Posted Feb 01, 2014
Replied 1 hour later
I've remapped duck to a new action in three separate maps: time-travel in Braid, shield in Bastion, and create shadow in Shadows of Time. So far it's always worked.
Avatar
HMW
806 Posts
Posted Feb 02, 2014
Replied 16 hours later

gallardo wrote:
What do you think if I just use the "duck" button? you still crouch but also trigger the new action.
No problem while flying, just a little stutter when on ground.

If you can do that without causing problems with normal ducking, then I'd say go for it.
I've played Felix's "Shadow of Time" and I think it works fine there.

Avatar
gallardo
85 Posts
Posted Feb 02, 2014
Replied 6 hours later
I've played it too to understand.
Doing the same would be ok; not the most elegant solution, but good enough for me.
I'd prefer exploit the "quick_ping" button, but I dont know how yet.
Avatar
FelixGriffin
2,680 Posts
Posted Feb 02, 2014
Replied 2 hours later
Why do you assume it's possible?
Avatar
DaMaGepy
361 Posts
Posted Feb 02, 2014
Replied 9 minutes later
I use ESDF for movement, and almost all other key is bind to something (mapping things, wireframe, visleaves, infos, framerate, hide portalgun, add portalgun, noclip, reload, loadgame etc.) so I would be angry if someone deletes/overwrites any (since I cant remember all of those)
Avatar
gallardo
85 Posts
Posted Feb 02, 2014
Replied 3 minutes later
I assume it until I prove it wrong.

Anyway, I was quite happy with your methond, until I discovered that you cannot "duck" after a jump...
Honestly I wanted to check your map back again, but I can't now, so I'm not sure it happesn there too.

that's a big issue for me

@DaMaGepy
I'd like to avoid it. felix's method almost worked!

Avatar
CamBen
973 Posts
Posted Feb 03, 2014
Replied 15 hours later
Little bit of a topic shift here, but stil related. If I am trying to make a map pack with custom controls used throughout, such as swap weapon, revert to previous, flashlight, etc.... Would it be just easier to make it as a mod?

With a mod I might also be able to use custom scene files and bik videos as well which would be nice.

But mainly I'm asking because as said, you can't crouch during a jump or while falling, and I have more than 1 binding.

(I know it sounds better to use in the portal 1 engine, but I'd really like to have all the portal 2 related entities, plus the portal 2 style, physics engine, and models/textures).

Avatar
gallardo
85 Posts
Posted Feb 03, 2014
Replied 3 hours later
to be precise, you can crouch while falling, if you have not jumped, like by running off a cliff.

I think it's better to keep it a map as much as possible, to be workshop compatible.

Avatar
CamBen
973 Posts
Posted Feb 03, 2014
Replied 5 hours later
Well either way I'd probably have to use more bindings than just crouch, because I need at least 4 bindings. Workshop compatibility isn't an issue, i could just post a map demo on the workshop and have it say at the end that there is a full download link in the description with a full instruction area for noobs. The main issue is whether or not I should release it as a mod I guess, because a small map pack would be enough to fill a mod. Maybe just classify it as a mini mod? I don't know.
Avatar
gallardo
85 Posts
Posted Feb 04, 2014
Replied 9 hours later
workshop's main advantage is smooth/easy installation.
I'd go for a mod if it really adds something.
Avatar
Fracture
797 Posts
Posted Feb 26, 2015
Replied 1 year later
I followed the instructions exactly but for some reason my game refuses to acknowledge bindings to entities.
It just keeps saying "bind <key> [command] : attach a command to a key"

was there an update that changed this or something?

Advertisement
Registered users don't see ads! Register now!
Avatar
CamBen
973 Posts
Posted Feb 27, 2015
Replied 9 hours later
Did you correctly insert the "quotes" around the command you were trying to bind?