Helliot1
Owner of Empire Online
- Joined
- Jul 26, 2017
- Messages
- 315
- Solutions
- 1
- Reaction score
- 59
Hello guys! How are you?
1) I have a module that has a function to create a Widget, according to an array like this.
2) In my Lua file, I have this function to create the Widget with all the above information.
2) In my OTUI I have a label with all this information like iconeSpell, nomeSpell, castingSpell, manaSpell, magicSpell, and the module looks like this:

3) Lastly and most importantly, there is also @onCheckChange that activates when I change the spell. What I need to know is: How can I get the name of the selected spell? Like iconeSpell, nomeSpell, castingSpell, manaSpell, magicSpell.
1) I have a module that has a function to create a Widget, according to an array like this.
LUA:
-- vocation id [1]
warrior = { None = { nome = "None", casting = "Instant", mana = 0, magic = 0},
WeakHealing = { nome = "Weak Healing", casting = "Instant", mana = 10, magic = 0},
Recuperation = { nome = "Recuperation", casting = "Instant", mana = 40, magic = 3},
Light = { nome = "Light", casting = "Instant", mana = 20, magic = 1},
SpeedBoost = { nome = "Speed Boost", casting = "Instant", mana = 50, magic = 4},
Createfood = { nome = "Create Food", casting = "Instant", mana = 25, magic = 2},
SweepingSwipe = { nome = "Sweeping Swipe", casting = "Instant", mana = 60, magic = 5}
}
2) In my Lua file, I have this function to create the Widget with all the above information.
LUA:
local currentSpell = getVocationName()
for key,spell in pairs(currentSpell) do
local singleSpell = g_ui.createWidget('singleSpell', spellsList)
local iconeSpell = singleSpell:getChildById('iconeSpell')
iconeSpell:setImageSource('/images/game/spells/' .. key .. '')
local nomeSpell = singleSpell:getChildById('nomeSpell')
nomeSpell:setText(spell.nome)
local castingSpell = singleSpell:getChildById('castingSpell')
castingSpell:setText(spell.casting)
local manaSpell = singleSpell:getChildById('manaSpell')
manaSpell:setText(spell.mana .. ' mana')
local magicSpell = singleSpell:getChildById('magicSpell')
magicSpell:setText('magic level ' .. spell.magic .. '')
radioItems:addWidget(singleSpell)
end
2) In my OTUI I have a label with all this information like iconeSpell, nomeSpell, castingSpell, manaSpell, magicSpell, and the module looks like this:

CSS:
singleSpell < UICheckBox
font: verdana-11px-rounded
color: #c8c8c8
@onCheckChange: modules.game_spells.onSpellsBoxChecked(self)
InsideWindow
id: insideWindowSpellsBox
size: 42 42
anchors.top: parent.top
anchors.left: parent.left
margin-top: 5
margin-left: 5
Label
id: iconeSpell
font: verdana-11px-rounded
size: 40 40
color: #ffffff
anchors.top: insideWindowSpellsBox.top
anchors.left: insideWindowSpellsBox.left
margin-top: 1
margin-left: 1
Label
id: nomeSpell
font: verdana-11px-rounded
color: #ffffff
phantom: true
anchors.top: insideWindowSpellsBox.top
anchors.left: insideWindowSpellsBox.right
margin-top: 5
margin-left: 5
text-auto-resize: true
$checked on:
background-color: #c8c8c840
$!checked:
background-color: alpha
Label
id: castingSpell
font: verdana-11px-rounded
color: #8c8c8c
anchors.top: nomeSpell.bottom
anchors.left: nomeSpell.left
margin-top: 5
text-auto-resize: true
Label
id: manaSpell
font: verdana-11px-rounded
color: #c0c0ff
anchors.top: nomeSpell.top
anchors.right: parent.right
margin-right: 5
text-auto-resize: true
Label
id: magicSpell
font: verdana-11px-rounded
color: #82ff82
anchors.top: manaSpell.bottom
anchors.right: manaSpell.right
margin-top: 5
text-auto-resize: true
3) Lastly and most importantly, there is also @onCheckChange that activates when I change the spell. What I need to know is: How can I get the name of the selected spell? Like iconeSpell, nomeSpell, castingSpell, manaSpell, magicSpell.
LUA:
function onSpellsBoxChecked(widget)
if widget:isChecked() then
...
end
end