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> Code:
FastRide = { 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 Why isn't the keybind working?? |
Use a global variable instead of d() for this. You can't always rely on it for load situations. So make it something like test_var = false, then inside the function = true, then afterwards, use /script d(test_var)
So you can see if it's really calling it. |
It's really not calling it from the keybind because of the error code that claims the function is nil...
Code:
2018-02-08T19:31:32.375-06:00 |cff0000Lua Error: :1: function expected instead of nil :( But I can call it from the slash command... |
Have you tried
function FastRide.keySwitch() instead of FastRide.keySwitch = function() |
Quote:
Yeah, I tried that first - then went to the FastRide.keySwitch = function() to see if it would make a difference. It did not. |
From what you have posted I don't see a mistake either.
Try this: Code:
<Bindings> |
What about making it a standalone global function?
Try just calling a function named KeySwitch() from the bindings that just outputs to chat/var. |
Changing to
Code:
<Action name="FASTRIDE_SWITCH"> Code:
2018-02-09T09:24:34.222-06:00 |cff0000Lua Error: :1: = expected near '<eof>'|r |
Creating a global standalone function does work!
I just hate to pollute the global namespace... |
Found the problem!
I wanted to report back that I found what the problem was... and it was not in the keybinding code itself. :o
The name for my saved variables (specified in ZO_SavedVars:NewAccountWide() and ZO_SavedVars:NewCharacterIdSettings() and the manifest file) was the same as the namespace name for the addon. So, the addon namespace was being saved and reloaded by ZO_SavedVars and you cannot save functions as a saved variable - so those would get saved as value nil and reloaded that way. That was why the global function still worked - because it was in the _G namespace instead of the addon namespace. You can tell that you have this problem when you look at your addon saved variables file and find all sorts of addon namespace-level variables there, some of them with the value of nil and a generated comment saying that function is not a vaild type. Your addon's behaviour will be wildly unpredictable from toon to toon. Thank you to everyone for your help. |
Error in Lua
user:/AddOns/FasterTravel/FasterTravel.lua:487: attempt to index a nil value
stack traceback: user:/AddOns/FasterTravel/FasterTravel.lua:487: in function '__new_ZO_Dialogs_ShowPlatformDialog' <Locals> name = "FAST_TRAVEL_CONFIRM", node = tbl, params = tbl, nodeIndex = 56, dialog = ud </Locals> user:/AddOns/FasterTravel/FasterTravel.lua:519: in function 'hookFunction' <Locals> name = "FAST_TRAVEL_CONFIRM" </Locals> EsoUI/Libraries/Utility/ZO_Hook.lua:19: in function 'ZO_Dialogs_ShowPlatformDialog' |
Quote:
2nd The error message telly you alread where to post this message to. The comments of the addon "FasterTravel": http://www.esoui.com/downloads/info1...eleporter.html -> btw there are other addons replacing this one afaik. EasyTravel e.g. 3rd You could add info when this error message happens and you might get help then. |
All times are GMT -6. The time now is 09:08 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI