Jump to content

Dual keybinds?


Deltanic

Recommended Posts

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 
  

Link to comment
  • Moderators

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 ?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...