Jump to content

[Solved] unbindKey issue


Angelo.

Recommended Posts

Good day gents,

So, I got this piece of code Client side:

  
function bindKeyFunc(state) 
    if(state == "bind")then 
        local activeListString = "Page"..tostring(activeList) 
         
        local ID1, NAME1, CONTENT1, COMMAND1 = dataRetrieve( activeListString, "Bind1") 
        local ID2, NAME2, CONTENT2, COMMAND2 = dataRetrieve( activeListString, "Bind2") 
        local ID3, NAME3, CONTENT3, COMMAND3 = dataRetrieve( activeListString, "Bind3") 
        local ID4, NAME4, CONTENT4, COMMAND4 = dataRetrieve( activeListString, "Bind4") 
        local ID5, NAME5, CONTENT5, COMMAND5 = dataRetrieve( activeListString, "Bind5") 
        local ID6, NAME6, CONTENT6, COMMAND6 = dataRetrieve( activeListString, "Bind6") 
         
        bindKey ( "1", "down", COMMAND1, CONTENT1 ) 
        bindKey ( "2", "down", COMMAND2, CONTENT2 ) 
        bindKey ( "3", "down", COMMAND3, CONTENT3 ) 
        bindKey ( "4", "down", COMMAND4, CONTENT4 ) 
        bindKey ( "5", "down", COMMAND5, CONTENT5 ) 
        bindKey ( "6", "down", COMMAND6, CONTENT6 ) 
        outputChatBox("All keys bounded!") 
    elseif(state == "unbind")then 
         
        res1 = unbindKey ( "1", "down", COMMAND1 ) 
        res2 = unbindKey ( "2", "down", COMMAND2) 
        res3 = unbindKey ( "3", "down", COMMAND3) 
        res4 = unbindKey ( "4", "down", COMMAND4) 
        res5 = unbindKey ( "5", "down", COMMAND5) 
        res6 = unbindKey ( "6", "down", COMMAND6) 
        -- outputs are for testing 
        outputChatBox(tostring(res1)) 
        outputChatBox(tostring(res2)) 
        outputChatBox(tostring(res3)) 
        outputChatBox(tostring(res4)) 
        outputChatBox(tostring(res5)) 
        outputChatBox(tostring(res6)) 
    end 
end 
  

So the thing is, i'm using this function somewhere else with either "bind" or "unbind" as arguments ( string type arguments).

There is no problem with the binding part, that works perfectly, but there is an issue with the unbindKey part because it returns false and the keys doesn't get unbinded.

in case you're wondering, dataRetrieve() is a function made on the same script, and it works perfectly.

No debug warnings/errors show.

I'd like to know if anyone have experienced the same issue and how to fix it, thanks in advance :)

Edited by Guest
Link to comment

Never mind, after running some tests, I just realized how stupid my mistake was.

Apparently I assigned the commands ( line 22 to line 27 ) as local, so the second block "elseif"(line 20) doesn't recognize the commands, so it doesn't gets unbinded.

Silly me.

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...