View Single Post
02/08/18, 07:50 PM   #1
Shadowfen
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 83
KeyBinding - function expected instead of nil

I don't know anymore what how to find what I'm doing wrong.

I've got bindings.xml (formerly named Bindings.xml):
Code:
<Bindings>
  <Layer name="SI_KEYBINDINGS_CATEGORY_GENERAL">
    <Category name="Fast Ride">
      <Action name="FASTRIDE_SWITCH">
        <Down>FastRide.keySwitch()</Down>
      </Action>
    </Category>
  </Layer>
</Bindings>
I've got FastRide.lua:
Code:
FastRide = {
	name = "FastRide",
}
local FR = FastRide
ZO_CreateStringId("SI_BINDING_NAME_FASTRIDE_SWITCH", "Toggle Rapids")

FastRide.keySwitch = function()
	d("keySwitch: start")
	d("keySwitch: end")
end

local function onAddonLoaded(ev, addonName)
	if addonName == FastRide.name then
		EVENT_MANAGER:UnregisterForEvent(FastRide.name, EVENT_ADD_ON_LOADED)
	end
end

EVENT_MANAGER:RegisterForEvent(FastRide.name, EVENT_ADD_ON_LOADED, onAddonLoaded)

SLASH_COMMANDS["/fastride.key"] = function()
	FR.keySwitch()
end
FastRide.lua is followed by bindings.xml in the manifest.

All other addons are turned off (except for BugCatcher).

I can use the /fastride.key and get the messages in chat.
When I bind to a key and then use that key, I get a
Code:
2018-02-08T19:31:32.375-06:00 |cff0000Lua Error: :1: function expected instead of nil
stack traceback:
	:1: in function '(main chunk)'|r
in the interface.log.

Why isn't the keybind working??
  Reply With Quote