Download
(2 Kb)
Download
Updated: 03/06/20 06:13 PM
Pictures
File Info
Updated:03/06/20 06:13 PM
Created:03/06/20 06:13 PM
Monthly downloads:71
Total downloads:2,682
Favorites:0
MD5:
Simple Keybind
Version: 0.1.0
by: ShadowMau [More]
A simple example of how to add a keybinding to the in-game controls. This is more for my own personal use as a reference and practice for uploading future addons.

Use:

/st - display a simple diagnostic message to the chat window

Look under the Controls menu for the addon Simple Keybind (the text should be golden colored). Assign a keystroke to the option.

Check out my other addons listed in the top box.
0.1.0
*Initial release
Optional Files (0)


Post A Reply Comment Options
Unread 04/15/20, 06:55 PM  
ShadowMau
AddOn Author - Click to view AddOns

Forum posts: 23
File comments: 46
Uploads: 12
Re: Need help with a keybind AddOn

Originally Posted by Endymion72
So I've been spending way too much time trying to make a simple addon that keybinds the script to show or hide the group frame. I've followed your example well, and can't get it to work. I get an error of "attempt to recall a nil value" or something like that.

https://pastebin.com/ksQnySp0

Could you please check my work to see what I'm doing wrong? My txt and xml files should be perfect, so I don't think the issue is there. Do I need a command to run scripts? As far as I've researched, it seems that you should just be able to put "ZO_" scripts right into functions without issue.
The link you shared has the main lua file. Do you have a bindings.xml file? Without the xml file, you never tell the addon to display the options so they can be bound. Since you are getting an "attempt to call a nil value" error, I am guessing you have one. I made several modifications, and, to test, worked around the whole keybinding issue. Here is a working example complete with debugging checks, I changed it to be a slash command so I did not have to create a bindings.xml file. I also named the file tgf.lua.

I have found that usually when you get the "attempt to call a nil value" error, there is usually some form of syntax / typo. In this case, it started working when I added ToggleGroupFrames. to the function names.

You might want to install LibDebugLogger and DebugLogViewer to help you with the debugging process.

Code:
ToggleGroupFrames = {}
ToggleGroupFrames.name = "tgf"
 
function ToggleGroupFrames.HideGroup()
    d("hide the frames")
	ZO_UnitFramesGroups:SetHidden(true)
end
 
function ToggleGroupFrames.ShowGroup()
    d("show the frames")
	ZO_UnitFramesGroups:SetHidden(false)
end
 
function ToggleGroupFrames.Initialize()
    -- LUA is a scripted language, not a compiled language.  Thins is run
    -- in the order they appear.
    -- These calls must be *after* the function have been defined above
    ZO_CreateStringId('SI_BINDING_NAME_HIDE_GROUPFRAMES', "Hide Group Frames")
    ZO_CreateStringId('SI_BINDING_NAME_SHOW_GROUPFRAMES', "Show Group Frames")
end
   
function ToggleGroupFrames.OnAddOnLoaded(event, addonName)
    d(addonName)
	if addonName == ToggleGroupFrames.name then
        ToggleGroupFrames.Initialize()
        -- No need to check any more
        EVENT_MANAGER:UnregisterForEvent(ToggleGroupFrames.name, EVENT_ADD_ON_LOADED)
		SLASH_COMMANDS["/st1"] = ToggleGroupFrames.HideGroup
		SLASH_COMMANDS["/st2"] = ToggleGroupFrames.ShowGroup
		d("tgf loaded")
    end
end
 
EVENT_MANAGER:RegisterForEvent(ToggleGroupFrames.name, EVENT_ADD_ON_LOADED, ToggleGroupFrames.OnAddOnLoaded)
Report comment to moderator  
Reply With Quote
Unread 04/11/20, 09:49 PM  
Endymion72
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 4
Uploads: 1
Need help with a keybind AddOn

So I've been spending way too much time trying to make a simple addon that keybinds the script to show or hide the group frame. I've followed your example well, and can't get it to work. I get an error of "attempt to recall a nil value" or something like that.

https://pastebin.com/ksQnySp0

Could you please check my work to see what I'm doing wrong? My txt and xml files should be perfect, so I don't think the issue is there. Do I need a command to run scripts? As far as I've researched, it seems that you should just be able to put "ZO_" scripts right into functions without issue.
Last edited by Endymion72 : 04/11/20 at 09:49 PM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: