Game Development Community

Disabling keys

by Adam Beaumont · in Torque Game Engine · 08/20/2003 (2:31 am) · 3 replies

Is it possible to disable movement keys from script ? I want something where I can turn off the players movement keys and then turn them back on again later.

I can probably do this in C++ by intercepting the UpdateMove function and only allowing the parent call if I want moves to be processed (I think that should work). Just wondering if theres a way to do it from script - maybe messing around with the control object or something ?

Adam

#1
08/20/2003 (3:48 am)
One simple way would be to bind the movement keys to some dummy function temporarily.

Like:

moveMap.bind( keyboard, a, dummy );
moveMap.bind( keyboard, d, dummy );
moveMap.bind( keyboard, w, dummy );
moveMap.bind( keyboard, s, dummy );
moveMap.bind( keyboard, space, dummy );
moveMap.bind( mouse, xaxis, dummy );
moveMap.bind( mouse, yaxis, dummy );

function dummy(%val)
{
}
#2
08/20/2003 (5:03 am)
Yeah thats something I hadn't thought about. There is also a whole bunch of script functions that handle the key presses etc so I could have gone into each one and done an "If(!var) do as before".

I ended up putting a new flag into the player object so that updateMove isn't processed unless the flag is set and that seems to pretty much do it for the moment.
#3
08/20/2003 (5:35 am)
Um just a little fyi you shouldn't do it exactly like Ian said, though you should use the same concept. I suggest you make it so that the user can change his controls to what he/she wants rather then setting it in code and if you do that you have find out from script what exactly each of hte movement commands are mapped to. Then once you find that info out you would do what Ian does except to the keys you found. Then you have to revert correctly later on. It will take more work then just making the controls set in stone but it will be much better for the end user.