Thread Tools Display Modes
12/15/16, 02:43 PM   #1
Crabby654
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 19
Question Running into issues with LAM, first addon with it!

Hey there everyone. So I created a super basic addon way long ago, bigger chat window. Basically a brainless addon to create. But now I am attempting to create my own version of the "ESO Toolbox" addon called "Expanded Options", but I want to build it myself and have more options.

I am running into issues at the very start. I want to have a settings window for this addon in the Addon Settings Menu in the default UI, but it just is not working at all. I was trying to pull parts of code from other addons with very very basic LAM settings window in the addon settings menu part of the default UI.

As an example I pulled out the AlignGrid LAM parts of the main lua and put it into my addon, I changed all the relevant information to remove anything with AlignGrid to ExpandedOptions. The addon is recognized by ESO and it shows up in the ESO Addons and is enabled. However I am seeing nothing in the Addons Settings Menu.

I am at a loss of what to do. I am an incredible newbie with LUA and making addons, I have updated a couple buy basically just updating the TOC and Library files, nothing code related.

Here is the contents of ExpandedOptions.lua
Code:
local LAM2 = LibStub:GetLibrary("LibAddonMenu-2.0")

local panelData = {
		type = 'panel',
		name = 'ExpandedOptions',
		displayName = 'Expanded Options',
		author = 'Crabby654',
		version = '1.0',
		slashCommand = '/eopt',
	}

local restartRequired = '|t16:16:/esoui/art/progression/lock.dds|t You have to restart the game for these changes to take effect.';

local optionsData = {
	{
		type = 'header',
		name = 'Misc Settings',
		width = 'full',
	},
	{
		type = 'description',
		text = 'The following settings aren\'t availalbe in the standard game UI. They\'re either hidden or new and provided by this addon.',
		width = 'full',
	},
	{
		type = 'checkbox',
		name = 'Skip logos on game start',
		getFunc = function()
				return GetCVar('SkipPregameVideos') == '1'
			end,
		setFunc = function(value)
				if value then
					SetCVar('SkipPregameVideos', '1');
				else
					SetCVar('SkipPregameVideos', '0');
				end
			end,
		default = false,
	},
	{
		type = 'dropdown',
		name = 'Screenshot format',
		choices = {'PNG', 'BMP', 'JPG'},
		getFunc = function()
				return GetCVar('ScreenshotFormat.2')
			end,
		setFunc = function(value)
				SetCVar('ScreenshotFormat.2', value)
			end,
		width = 'full',
		default = 'PNG',
	},
	{
		type = 'dropdown',
		name = 'Rendering engine to be used',
		choices = {'DirectX 9', 'DirectX 11', 'OpenGL', 'Let the game decide'},
		getFunc = function()
				local v = GetCVar('GraphicsDriver.7')
				if v == 'D3D11' then
					return 'DirectX 11'
				elseif v == 'D3D9' then
					return 'DirectX 9'
				elseif v == 'OPENGL' then
					return 'OpenGL'
				else
					return 'Let the game decide'
				end
			end,
		setFunc = function(value)
				if value == 'DirectX 11' then
					SetCVar('GraphicsDriver.7', 'D3D11')
				elseif value == 'DirectX 9' then
					SetCVar('GraphicsDriver.7', 'D3D9')
				elseif value == 'OpenGL' then
					SetCVar('GraphicsDriver.7', 'OPENGL')
				else
					SetCVar('GraphicsDriver.7', '')
				end
			end,
		width = 'full',
		warning = restartRequired,
		default = '',
	},
	{
		type = 'description',
		title = 'Expand UI Memory',
		text = 'By default, ESO reserves 64 MB of RAM for addons and UI code. If you\'re using many complex addons you might actually run out of memory.',
		width = 'full',
	},
	{
		type = 'description',
		text = 'LUA UI memory limit',
		width = 'half',
	},
	{
		type = 'dropdown',
		--name = 'Lua UI Memory Limit',
		choices = {'64MB', '128MB', '256MB', '512MB'},
		getFunc = function()
				return GetCVar('LuaMemoryLimitMB') .. 'MB'
			end,
		setFunc = function(value)
				SetCVar('LuaMemoryLimitMB', value:gsub('MB', ''));
			end,
		default = '64MB',
		warning = 'Reserving too much memory for the game UI might have negative impact on your game performance. Only do so if you really have to.\n\n' .. restartRequired,
		width = 'half',
	}
}

----------------------------------------------------------------------------------------------------------

---------------------------------- Addon Initialization --------------------------------------------------

local function AddOnLoaded(eventID,addonName)
	if addonName == "ExpandedOptions" then
		EVENT_MANAGER:UnregisterForEvent("ExpandedOptions_Start",eventID)
		LAM2:RegisterAddonPanel("ExpandedOptionsOptions", panelData)
        LAM2:RegisterOptionControls("ExpandedOptionsOptions", optionsData)
		setupSavedVars()
		ExpandedOptionsWindow = WM:CreateTopLevelWindow("ExpandedOptions")
		ExpandedOptionsWindow:SetAnchorFill(GuiRoot)
		ExpandedOptionsWindow:SetDrawLayer(DL_BACKGROUND)
		ExpandedOptionsWindow:SetMouseEnabled(false)
		SLASH_COMMANDS["/eopt"] = function()
			if ExpandedOptionsWindow:IsHidden() then
				ExpandedOptionsWindow:SetHidden(false)
			else
				ExpandedOptionsWindow:SetHidden(true)
			end
		end
		createGrid()
		hideGrid()
	end
end

EVENT_MANAGER:RegisterForEvent("ExpandedOptions_Start",EVENT_ADD_ON_LOADED,AddOnLoaded)
Here are the contents of ExpandedOptions.txt
Code:
## Title: Expanded Options
## Description: Shows more options for tweaking ESO
## APIVersion: 100017
## Author: Crabby654
## Version: 1.0.0

libs\LibStub\LibStub.lua
libs\LibAddonMenu-2.0\LibAddonMenu-2.0.lua
libs\LibAddonMenu-2.0\controls\panel.lua
libs\LibAddonMenu-2.0\controls\submenu.lua
libs\LibAddonMenu-2.0\controls\button.lua
libs\LibAddonMenu-2.0\controls\checkbox.lua
libs\LibAddonMenu-2.0\controls\colorpicker.lua
libs\LibAddonMenu-2.0\controls\custom.lua
libs\LibAddonMenu-2.0\controls\description.lua
libs\LibAddonMenu-2.0\controls\dropdown.lua
libs\LibAddonMenu-2.0\controls\editbox.lua
libs\LibAddonMenu-2.0\controls\header.lua
libs\LibAddonMenu-2.0\controls\slider.lua
libs\LibAddonMenu-2.0\controls\texture.lua

ExpandedOptions.lua

; This Add-on is not created by, affiliated with or sponsored by ZeniMax
; Media Inc. or its affiliates. The Elder Scrolls® and related logos are
; registered trademarks or trademarks of ZeniMax Media Inc. in the United
; States and/or other countries. All rights reserved.
;
; You can read the full terms at:
; https://account.elderscrollsonline.com/add-on-terms

Last edited by Crabby654 : 12/15/16 at 03:26 PM.
  Reply With Quote
12/15/16, 03:09 PM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by Crabby654 View Post
Hey there everyone. So I created a super basic addon way long ago, bigger chat window. Basically a brainless addon to create. But now I am attempting to create my own version of the "ESO Toolbox" addon called "Expanded Options", but I want to build it myself and have more options.

I am running into issues at the very start. I was trying to pull parts of code from other addons with very very basic LAM settings window in the addon settings menu part of the default UI.

As an example I pulled out the AlignGrid LAM parts of the main lua and put it into my addon, I changed all the relevant information to remove anything with AlignGrid to ExpandedOptions. The addon is recognized by ESO and it shows up in the ESO Addons and is enabled. However I am seeing nothing in the Addons Settings Menu.

I am at a loss of what to do. I am an incredible newbie with LUA and making addons, I have updated a couple buy basically just updating the TOC and Library files, nothing code related.
Which issue?
And look at your manifest txt at LibStub: Is it lib or libs?
  Reply With Quote
12/15/16, 03:27 PM   #3
Crabby654
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 19
Originally Posted by votan View Post
Which issue?
And look at your manifest txt at LibStub: Is it lib or libs?
Oh wow I was typing so fast I forgot haha. I edited the OP with my issue but it is basically this, I want to have a settings window for this addon in the Addon Settings Menu in the default UI, but it just is not working at all.

I also edited this line in the .txt file - libs\LibStub\LibStub.lua
It now matches the other library file locations.

Still no menu working.
  Reply With Quote
12/15/16, 06:54 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Is the addon loaded? Did you test with d("debug message") in your addon loaded function to see how far the addon gets?
Are the variables optionData and panel data inside any function or (only local defined in this function then) or directly in the addon file (thus global locals within your addon and known to the function onAddonLoaded this way)?
  Reply With Quote
12/16/16, 02:19 AM   #5
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Next question: Where do you define WM?

Code:
local function AddOnLoaded(eventID,addonName)
	if addonName == "ExpandedOptions" then
		EVENT_MANAGER:UnregisterForEvent("ExpandedOptions_Start",eventID)
		LAM2:RegisterAddonPanel("ExpandedOptionsOptions", panelData)
        LAM2:RegisterOptionControls("ExpandedOptionsOptions", optionsData)
		setupSavedVars()
		ExpandedOptionsWindow = WM:CreateTopLevelWindow("ExpandedOptions")
		ExpandedOptionsWindow:SetAnchorFill(GuiRoot)
		ExpandedOptionsWindow:SetDrawLayer(DL_BACKGROUND)
		ExpandedOptionsWindow:SetMouseEnabled(false)
		SLASH_COMMANDS["/eopt"] = function()
			if ExpandedOptionsWindow:IsHidden() then
				ExpandedOptionsWindow:SetHidden(false)
			else
				ExpandedOptionsWindow:SetHidden(true)
			end
		end
		createGrid()
		hideGrid()
	end
end

Last edited by votan : 12/16/16 at 06:06 AM.
  Reply With Quote
12/16/16, 09:36 AM   #6
Crabby654
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 19
Originally Posted by Baertram View Post
Is the addon loaded? Did you test with d("debug message") in your addon loaded function to see how far the addon gets?
Are the variables optionData and panel data inside any function or (only local defined in this function then) or directly in the addon file (thus global locals within your addon and known to the function onAddonLoaded this way)?
I am not sure if the addon is loading, how do I do the debug message to test it?

Originally Posted by votan View Post
Next question: Where do you define WM?

Code:
local function AddOnLoaded(eventID,addonName)
	if addonName == "ExpandedOptions" then
		EVENT_MANAGER:UnregisterForEvent("ExpandedOptions_Start",eventID)
		LAM2:RegisterAddonPanel("ExpandedOptionsOptions", panelData)
        LAM2:RegisterOptionControls("ExpandedOptionsOptions", optionsData)
		setupSavedVars()
		ExpandedOptionsWindow = WM:CreateTopLevelWindow("ExpandedOptions")
		ExpandedOptionsWindow:SetAnchorFill(GuiRoot)
		ExpandedOptionsWindow:SetDrawLayer(DL_BACKGROUND)
		ExpandedOptionsWindow:SetMouseEnabled(false)
		SLASH_COMMANDS["/eopt"] = function()
			if ExpandedOptionsWindow:IsHidden() then
				ExpandedOptionsWindow:SetHidden(false)
			else
				ExpandedOptionsWindow:SetHidden(true)
			end
		end
		createGrid()
		hideGrid()
	end
end
I am not...sure. Ugh maybe I bit off more than I can chew with creating an addon. I should probably have tried to create a settings with LAM from scratch instead of pulling it from another, but dang its hard to find guides for that
  Reply With Quote
12/18/16, 11:53 AM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Look into the LAM folder (download it totally fresh without addons from www.esoui.com http://www.esoui.com/downloads/info7-LibAddonMenu.html). There is an example.lua file in there.

WM should be the WINDOW_MANAGER so you need to define it with local wm = WINDOW_MANAGER or use WINDOW_MANAGER instead of WM.
  Reply With Quote
12/18/16, 12:29 PM   #8
Crabby654
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 19
Originally Posted by Baertram View Post
Look into the LAM folder (download it totally fresh without addons from www.esoui.com http://www.esoui.com/downloads/info7-LibAddonMenu.html). There is an example.lua file in there.

WM should be the WINDOW_MANAGER so you need to define it with local wm = WINDOW_MANAGER or use WINDOW_MANAGER instead of WM.
So that was an awesome idea and didn't realize a template for it was that readily available. However I am still not getting any panel or window to show up. If it helps when I type /extopt (my slash command) it says "Invalid Command"
Alright this is what I have so far:

ExtendedOptions.txt
Code:
## Title: Extended Options
## Description: Shows more options for tweaking ESO that are available in the default UI.
## APIVersion: 100017
## Author: Crabby654
## Version: 1.0.0

libs\LibStub\LibStub.lua
libs\LibAddonMenu-2.0\LibAddonMenu-2.0.lua
libs\LibAddonMenu-2.0\controls\panel.lua
libs\LibAddonMenu-2.0\controls\submenu.lua
libs\LibAddonMenu-2.0\controls\button.lua
libs\LibAddonMenu-2.0\controls\checkbox.lua
libs\LibAddonMenu-2.0\controls\colorpicker.lua
libs\LibAddonMenu-2.0\controls\custom.lua
libs\LibAddonMenu-2.0\controls\description.lua
libs\LibAddonMenu-2.0\controls\dropdown.lua
libs\LibAddonMenu-2.0\controls\editbox.lua
libs\LibAddonMenu-2.0\controls\header.lua
libs\LibAddonMenu-2.0\controls\slider.lua
libs\LibAddonMenu-2.0\controls\texture.lua

ExtendedOptions.lua

; This Add-on is not created by, affiliated with or sponsored by ZeniMax
; Media Inc. or its affiliates. The Elder Scrolls® and related logos are
; registered trademarks or trademarks of ZeniMax Media Inc. in the United
; States and/or other countries. All rights reserved.
;
; You can read the full terms at:
; https://account.elderscrollsonline.com/add-on-terms
ExtendedOptions.lua
Code:
local panelData = {
    type = "panel",
    name = "Extended Options",
    displayName = "Extended Options",
    author = "Crabby654",
    version = "1.0.0",
    slashCommand = "/extopt",	--(optional) will register a keybind to open to this panel
    registerForRefresh = true,	--boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown)
    registerForDefaults = true,	--boolean (optional) (will set all options controls back to default values)
}

local optionsTable = {
    [1] = {
        type = "header",
        name = "My Header",
        width = "full",	--or "half" (optional)
    },
    [2] = {
        type = "description",
        --title = "My Title",	--(optional)
        title = nil,	--(optional)
        text = "My description text to display. blah blah blah blah blah blah blah - even more sample text!!",
        width = "full",	--or "half" (optional)
    },
    [3] = {
        type = "dropdown",
        name = "My Dropdown",
        tooltip = "Dropdown's tooltip text.",
        choices = {"table", "of", "choices"},
        getFunc = function() return "of" end,
        setFunc = function(var) print(var) end,
        width = "half",	--or "half" (optional)
        warning = "Will need to reload the UI.",	--(optional)
    },
    [4] = {
        type = "dropdown",
        name = "My Dropdown",
        tooltip = "Dropdown's tooltip text.",
        choices = {"table", "of", "choices"},
        getFunc = function() return "of" end,
        setFunc = function(var) print(var) end,
        width = "half",	--or "half" (optional)
        warning = "Will need to reload the UI.",	--(optional)
    },
    [5] = {
        type = "slider",
        name = "My Slider",
        tooltip = "Slider's tooltip text.",
        min = 0,
        max = 20,
        step = 1,	--(optional)
        getFunc = function() return 3 end,
        setFunc = function(value) d(value) end,
        width = "half",	--or "half" (optional)
        default = 5,	--(optional)
    },
    [6] = {
        type = "button",
        name = "My Button",
        tooltip = "Button's tooltip text.",
        func = function() d("button pressed!") end,
        width = "half",	--or "half" (optional)
        warning = "Will need to reload the UI.",	--(optional)
    },
    [7] = {
        type = "submenu",
        name = "Submenu Title",
        tooltip = "My submenu tooltip",	--(optional)
        controls = {
            [1] = {
                type = "checkbox",
                name = "My Checkbox",
                tooltip = "Checkbox's tooltip text.",
                getFunc = function() return true end,
                setFunc = function(value) d(value) end,
                width = "half",	--or "half" (optional)
                warning = "Will need to reload the UI.",	--(optional)
            },
            [2] = {
                type = "colorpicker",
                name = "My Color Picker",
                tooltip = "Color Picker's tooltip text.",
                getFunc = function() return 1, 0, 0, 1 end,	--(alpha is optional)
                setFunc = function(r,g,b,a) print(r, g, b, a) end,	--(alpha is optional)
                width = "half",	--or "half" (optional)
                warning = "warning text",
            },
            [3] = {
                type = "editbox",
                name = "My Editbox",
                tooltip = "Editbox's tooltip text.",
                getFunc = function() return "this is some text" end,
                setFunc = function(text) print(text) end,
                isMultiline = false,	--boolean
                width = "half",	--or "half" (optional)
                warning = "Will need to reload the UI.",	--(optional)
                default = "",	--(optional)
            },
        },
    },
    [8] = {
        type = "custom",
        reference = "MyAddonCustomControl",	--unique name for your control to use as reference
        refreshFunc = function(customControl) end,	--(optional) function to call when panel/controls refresh
        width = "half",	--or "half" (optional)
    },
    [9] = {
        type = "texture",
        image = "EsoUI\\Art\\ActionBar\\abilityframe64_up.dds",
        imageWidth = 64,	--max of 250 for half width, 510 for full
        imageHeight = 64,	--max of 100
        tooltip = "Image's tooltip text.",	--(optional)
        width = "half",	--or "half" (optional)
    },
}

local LAM = LibStub("LibAddonMenu-2.0")
LAM:RegisterAddonPanel("ExtendedOptions", panelData)
LAM:RegisterOptionControls("ExtendedOptions", optionsTable)
Folders are
Extended Options -> ExtendedOptions.txt ExtendedOptions.lua libs
libs -> LibAddonMenu-2.0 LibStub LibAddonMenu-2.0.txt
  Reply With Quote
12/18/16, 01:33 PM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Ok, please put your WHOLE addon, including the lua files, into a ZIP archive and upload it here so we can see all code of the addon.

If you simply put the LAM menu into your file ExtendedOptions.lua., and there is no EVENT_ADDON_LOADED int here which "enables your addon" and starts to call the LAM object etc. you won't see anything. So please provide the WHOLE code of your addon here so we can check and help you.

Thanks
  Reply With Quote
12/18/16, 03:39 PM   #10
Crabby654
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 19
Originally Posted by Baertram View Post
Ok, please put your WHOLE addon, including the lua files, into a ZIP archive and upload it here so we can see all code of the addon.

If you simply put the LAM menu into your file ExtendedOptions.lua., and there is no EVENT_ADDON_LOADED int here which "enables your addon" and starts to call the LAM object etc. you won't see anything. So please provide the WHOLE code of your addon here so we can check and help you.

Thanks
Alrighty here is the addon zip attached to this reply. Also this is a super basic addon I am making, essentially I just want a menu in the addon settings page in the default UI to change CVars in the usersettings file.
Attached Files
File Type: zip Extended Options.zip (43.4 KB, 365 views)
  Reply With Quote
12/18/16, 03:46 PM   #11
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Looked quickly at it and ...

http://wiki.esoui.com/Main_Page
http://wiki.esoui.com/Getting_Started
http://wiki.esoui.com/Writing_your_first_addon
http://wiki.esoui.com/SimpleNotebookTutorial/part1

I would also say that when you don't understand something, look at how others did and do same.
  Reply With Quote
12/18/16, 04:50 PM   #12
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
As I thought you are not building an addon. You are just putting some lua source code for a LAM in your file and that's all
Please read the links that Ayantir provided and see how an addon must be build in the addon's lua file.
Especially the event like EVENT_ON_ADDON_LOADED etc.

The lua interpreter is reading your source code from the top of the fie downwards to the bottom so be sure to put your variables and functions etc. in the correct order, so that "called variables/functions" further down in your code will be declared above the code where they are called.
  Reply With Quote
12/18/16, 04:57 PM   #13
Crabby654
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 19
Originally Posted by Ayantir View Post
Looked quickly at it and ...

http://wiki.esoui.com/Main_Page
http://wiki.esoui.com/Getting_Started
http://wiki.esoui.com/Writing_your_first_addon
http://wiki.esoui.com/SimpleNotebookTutorial/part1

I would also say that when you don't understand something, look at how others did and do same.
Originally Posted by Baertram View Post
As I thought you are not building an addon. You are just putting some lua source code for a LAM in your file and that's all
Please read the links that Ayantir provided and see how an addon must be build in the addon's lua file.
Especially the event like EVENT_ON_ADDON_LOADED etc.

The lua interpreter is reading your source code from the top of the fie downwards to the bottom so be sure to put your variables and functions etc. in the correct order, so that "called variables/functions" further down in your code will be declared above the code where they are called.
Alrighty thank you for the links. I'll take a read through them and see what to do! I'm sorry if this was a super ridiculous thing to post about, I honestly thought that for what I had that at least a menu would show up, but I guess not! Time to take it all back to the drawing board.
  Reply With Quote
12/18/16, 05:26 PM   #14
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Without your addon around the menu the menu will not be shown as it relies on an addon construct in the back. If your addon is not loaded the menu won't be loaded
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Running into issues with LAM, first addon with it!

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