Thread Tools Display Modes
06/11/14, 01:24 PM   #1
ZunaSW
Join Date: Mar 2014
Posts: 37
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 ^^
  Reply With Quote
06/11/14, 01:41 PM   #2
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
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>
  Reply With Quote
06/11/14, 02:19 PM   #3
ZunaSW
Join Date: Mar 2014
Posts: 37
You are right. Thank you!! It worked : D
Like always, I get simple errors that I don't see xD
  Reply With Quote
06/11/14, 03:43 PM   #4
Halja
 
Halja's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 111
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
  Reply With Quote
06/12/14, 06:01 AM   #5
ZunaSW
Join Date: Mar 2014
Posts: 37
Hmm... You are right, Halja. Thanks for your help ^^
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Key Binding Problem

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off