ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Key Binding Problem (https://www.esoui.com/forums/showthread.php?t=1769)

ZunaSW 06/11/14 01:24 PM

Key Binding Problem
 
Hello all, sorry my english.

I'm now testing key bindings, and I readed a lot of them in the forums and in the wiki. I followed all the tutorials I found, and readed a lot of posts about them, but I can't make my key binding to work. I can select the key I want in the controls>key binding menu, but when I press the key I get this error:

Code:

:1: function expected instead of nil
stack traceback:
        :1: in function '(main chunk)'

Here is my bindings.xml

Code:

<Bindings>
  <Layer name="General">
    <Category name="Test">
      <Action name="TOGGLE_TEST">
        <Down>OnKeyDown()</Down>
      </Action>
    </Category>
  </Layer>
</Bindings>


bindings.lua

Code:

ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_TEST", "Toggle Test")

And my addon lua

Code:

BindingTest= {}

BindingTest.name = "Binding Test"

local wm = GetWindowManager()
local test = wm:CreateTopLevelWindow(nil)
test:SetDimensions(128,256)
test:SetAnchor(BOTTOMRIGHT,GuiRoot,BOTTOMRIGHT,0,0)
testb = wm:CreateControl(nil, test, CT_TEXTURE)
testb:SetTexture("BindingTest/textures/test.dds")
testb:SetAnchorFill(test)
testb:SetHidden(true)

function BindingTest.OnKeyDown()
                testb:SetHidden(false)
end

Where I'm failing? Thank you ^^

Sasky 06/11/14 01:41 PM

You're trying to reference a function called OnKeyDown() but your function is named BindingTest.OnKeyDown()

Try
xml Code:
  1. <Bindings>
  2.   <Layer name="General">
  3.     <Category name="Test">
  4.       <Action name="TOGGLE_TEST">
  5.         <Down>BindingTest.OnKeyDown()</Down>
  6.       </Action>
  7.     </Category>
  8.   </Layer>
  9. </Bindings>

ZunaSW 06/11/14 02:19 PM

You are right. Thank you!! It worked : D
Like always, I get simple errors that I don't see xD

Halja 06/11/14 03:43 PM

FYI:
They way you have the bindings file won't work if the player is in French or German language mode. ZOS is using the name attributes of the bindings XML to build the game menu for key binding settings. The layer name must become "General" in the language of the player.
English -- German -- French
"General" = "Allgemein" = "Général"

There are localization string variables. The "SI_" table is global for internationalized strings. The one for the layer is called SI_KEYBINDINGS_LAYER_GENERAL.

Your bindings file should end up looking something like this:
Code:

<Bindings>
        <Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
                <Category name="Test">
                        <Action name="TOGGLE_TEST">
                                <Down>BindingTest.OnKeyDown()</Down>
                        </Action>
                </Category>
        </Layer>
</Bindings>

--Cheers

ZunaSW 06/12/14 06:01 AM

Hmm... You are right, Halja. Thanks for your help ^^


All times are GMT -6. The time now is 09:41 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI