botanist Posted March 20, 2011 Posted March 20, 2011 How do people do this? I'm doing this, but that doesn't work. key1 = "a" key2 = "b" function whenResourceStarts ( ) bindKey ( key1, "down", onKey ) bindKey ( key2, "down", onKey ) end function onKey ( key ) if key == key1 and getKeyState ( key2 ) ~= "down" then return elseif key == key2 and getKeyState ( key1 ) ~= "down" then return end -- If the above is passed, go on, but it won't for some reason end
Moderators Citizen Posted March 20, 2011 Moderators Posted March 20, 2011 Is it in client or server-side ?
botanist Posted March 20, 2011 Author Posted March 20, 2011 Client. As most of my scripts. I'm trying to avoid every serverside thing as much as possible
Moderators Citizen Posted March 20, 2011 Moderators Posted March 20, 2011 You want to make an universal function ? ( I means one function for all bindKey ) ? Try this debug code: key1 = "a" key2 = "b" function whenResourceStarts ( ) bindKey ( key1, "down", onKey ) bindKey ( key2, "down", onKey ) end function onKey ( key, keyState ) outputChatBox( key.." "..getKeyState ( key1 ).." "..getKeyState ( key2 ) if key == key1 and getKeyState ( key2 ) ~= "down" then return elseif key == key2 and getKeyState ( key1 ) ~= "down" then return end -- If the above is passed, go on, but it won't for some reason end And are you sure: if key == key1 and getKeyState ( key2 ) ~= "down" then return I think it's: if key == key1 and getKeyState ( key1 ) ~= "down" then return no ?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now