Thread Tools Display Modes
02/23/23, 12:05 PM   #1
zHeMaa
Join Date: Feb 2023
Posts: 3
Question Variables LAM

Hi, I've been trying for a few days to make a selection in LAM (type = "dropdown",) work...

In game I get to see the dropdown. But even if I put data there is no effect (I was trying it with a message in the game chat "d(" but it never worked)

My idea is to show information about some sets.

Since I'm asking around here, and I know many of you are professionals in LUA, I'm going to ask what I would really like to achieve..

I have a "dropdown" in LAM2 (visible, but not functional), I would like for example when selecting Dark Convergence to activate some variables corresponding to that SET.

LAM2 code:
Code:
[4] = {
        type = "dropdown",
        name = "SETS",
        choices = {"Dark Convergence", "Perfected Void Bash"},
        getFunc = function() return addonname.Sets end,
        setFunc = function(value) addonname.Sets = value end,
    },

My main LUA file:
Code:
function addonname.SetData()
    addonname.Sets = {
	    --["Dark Convergence"] = {
        [1] = {
			PROC_NAME = "Dark Convergence",
			PROC_COOLDOWN = 25000,
			PROC_ID = 159388,
		},
    --["Perfected Void Bash"] = {
        [2] = {
			PROC_NAME = "Perfected Void Bash",
			PROC_COOLDOWN = 13000,
			PROC_ID = 147744,
        },
}
end
I have to say that I see results as I would like BUT without making a selection, that is, I have some 100% functional variables, but the one that I want to make LAM change from one set to another, is not saved. (in short, it doesn't work) So I always see the initial variables of my addon.

That's all, I don't speak English (this post has been translated), regards!

Last edited by zHeMaa : 02/23/23 at 12:43 PM.
  Reply With Quote
02/23/23, 12:32 PM   #2
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 642
The value has to be recognized somewhere and you can't reuse it. Then once Lam sets the value, then change the global set variable you want. The setFunc for Lam can call a function.

What language do you speak?

Code:
local function SetData()
  if addonname.Sets == "Dark Convergence" then
   <Do Stuff>
  elseif addonname.Sets == "Perfected Void Bash" then
   <Do Stuff>
  end
end

-- LAM Menu Code
<SNIP>
[4] = {
    type = "dropdown",
    name = "SETS",
    choices = {"Dark Convergence", "Perfected Void Bash"},
    getFunc = function() return addonname.Sets end,
    setFunc = function(value) 
      addonname.Sets = value 
      SetData()
    end,
},

Last edited by Sharlikran : 02/23/23 at 12:47 PM.
  Reply With Quote
02/23/23, 12:52 PM   #3
zHeMaa
Join Date: Feb 2023
Posts: 3
Originally Posted by Sharlikran View Post
The value has to be recognized somewhere and you can't reuse it. Then once Lam sets the value, then change the global set variable you want. The setFunc for Lam can call a function.

What language do you speak?

Code:
local function SetData()
  if addonname.Sets == "Dark Convergence" then
   <Do Stuff>
  elseif addonname.Sets == "Perfected Void Bash" then
   <Do Stuff>
  end
end

-- LAM Menu Code
<SNIP>
[4] = {
    type = "dropdown",
    name = "SETS",
    choices = {"Dark Convergence", "Perfected Void Bash"},
    getFunc = function() return addonname.Sets end,
    setFunc = function(value) 
      addonname.Sets = value 
      SetData()
    end,
},
Thanks for answering, do you mean that it has some "base" variables?

I have some of them at the top of the main file. The addon, as it is, works... but what has been said, I can't make the change from one set to another through LAM2.

Regards!

Code:
-- Varaiables
addonname.NAME = "addonname"
addonname.PROC_NAME = "Dark Convergence"
addonname.PROC_COOLDOWN = 25000
addonname.PROC_ID = 159388
  Reply With Quote
02/23/23, 01:07 PM   #4
zHeMaa
Join Date: Feb 2023
Posts: 3
Originally Posted by Sharlikran View Post
The value has to be recognized somewhere and you can't reuse it. Then once Lam sets the value, then change the global set variable you want. The setFunc for Lam can call a function.

What language do you speak?

Code:
local function SetData()
  if addonname.Sets == "Dark Convergence" then
   <Do Stuff>
  elseif addonname.Sets == "Perfected Void Bash" then
   <Do Stuff>
  end
end

-- LAM Menu Code
<SNIP>
[4] = {
    type = "dropdown",
    name = "SETS",
    choices = {"Dark Convergence", "Perfected Void Bash"},
    getFunc = function() return addonname.Sets end,
    setFunc = function(value) 
      addonname.Sets = value 
      SetData()
    end,
},
I tried the code that you gave me, and it gives me an error on the line (setFunc = function(value)), it must fail some nonsense...

(function expected instead of nil stack traceback)

And I speak Spanish, thank you!
  Reply With Quote
02/23/23, 01:09 PM   #5
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 642
Originally Posted by zHeMaa View Post
Thanks for answering, do you mean that it has some "base" variables?
Por decir, nada es automaticamente allí y parte de Lam. Simplamente tiene que cambiar que es requirido dependiendio en los condiciones.

Programando es muy sencillo, "Cuando se realiza un condición, haga un acción." Eso es todo.

Last edited by Sharlikran : 02/23/23 at 01:23 PM.
  Reply With Quote
02/23/23, 01:29 PM   #6
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 642
Originally Posted by zHeMaa View Post
I tried the code that you gave me, and it gives me an error
Este no es como un rompecabezas. No tienes lo que nececitas. Tu tienes que hacerlo, y saber que estas haciendo.

Que puse es codigo falso. Sólo muestra la idea. No es completo y no va funcionar asi.

Por ejemplo "addonname.Sets" no sirve si no tiene asi en su modificacion.

Last edited by Sharlikran : 02/23/23 at 01:45 PM.
  Reply With Quote
02/23/23, 01:35 PM   #7
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 642
Code:
-- Varaiables
addonname.NAME = "YourAddonName"  -- No puede poner algo coriente así
addonname.PROC_NAME = "Dark Convergence"
addonname.PROC_COOLDOWN = 25000
addonname.PROC_ID = 159388
addonname.Sets = addonname.PROC_NAME

local function SetData()
  if addonname.Sets == "Dark Convergence" then
    addonname.PROC_NAME = "Dark Convergence"
    addonname.PROC_COOLDOWN = 25000
    addonname.PROC_ID = 159388
  elseif addonname.Sets == "Perfected Void Bash" then
    addonname.PROC_NAME = "Perfected Void Bash"
    addonname.PROC_COOLDOWN = 13000
    addonname.PROC_ID = 147744
  end
end

optionsData = {
<corta>
[4] = {  -- Este no puede ser "4" si no es el cuarto parte del menu
    type = "dropdown",
    name = "SETS",
    choices = {"Dark Convergence", "Perfected Void Bash"},
    getFunc = function() return addonname.Sets end,
    setFunc = function(value) 
      addonname.Sets = value 
      SetData()
    end,
},
<corta>
} -- el fin de la tableta
Ahora tienes que copiarlo y pegarlo donde require. No puede usar eso asi. Tienes que hacer todos the cambios requiridos.

Si solo tiene nada mas un selección por el menu, necesita cambiar 4 a 1.

Code:
[4] = {  -- Este no puede "4" si no es el cuarto parte del menu
    type = "dropdown",
    name = "SETS",
    choices = {"Dark Convergence", "Perfected Void Bash"},
    getFunc = function() return addonname.Sets end,
    setFunc = function(value) 
      addonname.Sets = value 
      SetData()
    end,
},
Tambien esa no funciona asi, porque falta todo el resto requirido. Por ejemplo 1, 2, y 3.

Incluyendo todo lo que necesitas para LAM:RegisterAddonPanel(addonname.NAME, panelData) y LAM:RegisterOptionControls(addonname.NAME, optionsData)

Last edited by Sharlikran : 02/24/23 at 08:44 AM.
  Reply With Quote
02/23/23, 01:47 PM   #8
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 642
Esta extensión es tu obra, o estas modificando un extensión que ya existe?

Last edited by Sharlikran : 02/24/23 at 10:32 AM.
  Reply With Quote
02/24/23, 03:53 AM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,964
The setFunc of your LAM2 dropdown control is there to update your SavedVariables e.g. with the chosen set name from the choices table.
Hint: Also provide a choicesValues table with numbers instead of set names Strings! That way you can use the unique setId numbers instead of having to be carefull with translated setnames!

choices = {"setname1", "setname2"},
choicesValues = {1, 2},
getFunc = function() return yourSavedVariables.chosenSetId end,
setFunc = function(value)
-- Store value in your SavedVariables
yourSavedVariables.chosenSetId = value
--Update any visual information based on the chosen value (set's ID)
updateVisualSetData(value)
end,

As you choose an entry from the dropdown, e.g. setname2, the value 2 will be passed to the parameter "value" of the setFunc.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Variables LAM


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