Helliot1
Owner of Empire Online
- Joined
- Jul 26, 2017
- Messages
- 315
- Solutions
- 1
- Reaction score
- 58
Hello guys, I have been trying for a few days to solve a mistake, but it is impossible for me.
I need the help of you who understand this better than me!! Where am i going wrong?
I got this error on my OtClient:
This is my abilities.lua:
I need the help of you who understand this better than me!! Where am i going wrong?
I got this error on my OtClient:
Lua:
ERROR: lua function callback failed: LUA ERROR:
/corelib/util.lua:56: attempt to index local 'object' (a nil value)
stack traceback:
[C]: in function '__index'
/corelib/util.lua:56: in function 'connect'
/corelib/ui/uiscrollarea.lua:76: in function 'setVerticalScrollBar'
/corelib/ui/uiscrollarea.lua:19: in function </corelib/ui/uiscrollarea.lua:16>
ERROR: lua function callback failed: LUA ERROR:
/corelib/util.lua:56: attempt to index local 'object' (a nil value)
stack traceback:
[C]: in function '__index'
/corelib/util.lua:56: in function 'connect'
/corelib/ui/uiscrollarea.lua:76: in function 'setVerticalScrollBar'
/corelib/ui/uiscrollarea.lua:19: in function </corelib/ui/uiscrollarea.lua:16>
ERROR: protected lua call failed: LUA ERROR:
/corelib/ui/uiminiwindow.lua:358: attempt to index local 'contentsPanel' (a nil value)
stack traceback:
[C]: in function '__index'
/corelib/ui/uiminiwindow.lua:358: in function 'setContentMinimumHeight'
/game_abilities/abilities.lua:220: in function </game_abilities/abilities.lua:194>
ERROR: protected lua call failed: LUA ERROR:
/corelib/ui/uiminiwindow.lua:32: attempt to index a nil value
stack traceback:
[C]: in function '__index'
/corelib/ui/uiminiwindow.lua:32: in function 'minimize'
/corelib/ui/uiminiwindow.lua:77: in function </corelib/ui/uiminiwindow.lua:73>
ERROR: protected lua call failed: LUA ERROR:
/corelib/ui/uiminiwindow.lua:48: attempt to index a nil value
stack traceback:
[C]: in function '__index'
/corelib/ui/uiminiwindow.lua:48: in function 'maximize'
/corelib/ui/uiminiwindow.lua:75: in function </corelib/ui/uiminiwindow.lua:73>
This is my abilities.lua:
Lua:
healthBar = nil
manaBar = nil
experienceBar = nil
experienceTooltip = '%d%% left to advance.'
magiclevelTooltip = '%d%% left to advance.'
skillTooltip = '%d%% left to advance.'
local abilitiesWindow
local abilitiesTabBar
local abilities = {}
local skillsPanel
local talentsPanel
function init()
connect(LocalPlayer, {
onExperienceChange = onExperienceChange,
onLevelChange = onLevelChange,
onHealthChange = onHealthChange,
onManaChange = onManaChange,
onMagicLevelChange = onMagicLevelChange,
onBaseMagicLevelChange = onBaseMagicLevelChange,
onSkillChange = onSkillChange,
onBaseSkillChange = onBaseSkillChange
})
connect(g_game, {
onGameStart = refresh,
onGameEnd = offline
})
abilitiesWindow = g_ui.loadUI('abilities', modules.game_interface.getRightPanel())
abilitiesWindow:open()
abilitiesTabBar = abilitiesWindow:getChildById('abilitiesTabBar')
abilitiesTabBar:setContentWidget(abilitiesWindow:getChildById('abilitiesTabContent'))
skillsPanel = g_ui.loadUI('skills')
abilitiesTabBar:addTab(tr('Skills'), skillsPanel)
talentsPanel = g_ui.loadUI('talents')
abilitiesTabBar:addTab(tr('Talents'), talentsPanel)
healthBar = abilitiesWindow:recursiveGetChildById('healthBar')
manaBar = abilitiesWindow:recursiveGetChildById('manaBar')
experienceBar = abilitiesWindow:recursiveGetChildById('experienceBar')
if g_game.isOnline() then
local localPlayer = g_game.getLocalPlayer()
onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
onLevelChange(localPlayer, localPlayer:getLevel(), localPlayer:getLevelPercent())
end
g_keyboard.bindKeyDown('Ctrl+S', toggle)
refresh()
abilitiesWindow:setup()
end
function terminate()
disconnect(LocalPlayer, {
onExperienceChange = onExperienceChange,
onLevelChange = onLevelChange,
onHealthChange = onHealthChange,
onManaChange = onManaChange,
onMagicLevelChange = onMagicLevelChange,
onBaseMagicLevelChange = onBaseMagicLevelChange,
onSkillChange = onSkillChange,
onBaseSkillChange = onBaseSkillChange
})
disconnect(g_game, {
onGameStart = refresh,
onGameEnd = offline
})
g_keyboard.unbindKeyDown('Ctrl+S')
abilitiesWindow:destroy()
end
function expForLevel(level)
return math.floor((50*level*level*level)/3 - 100*level*level + (850*level)/3 - 200)
end
function expToAdvance(currentLevel, currentExp)
return expForLevel(currentLevel+1) - currentExp
end
function resetSkillColor(id)
local skill = abilitiesWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
widget:setColor('#c8c8aa')
end
function toggleSkill(id, state)
local skill = abilitiesWindow:recursiveGetChildById(id)
skill:setVisible(state)
end
function setSkillBase(id, value, baseValue)
if baseValue <= 0 or value < 0 then
return
end
local skill = abilitiesWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
if value > baseValue then
widget:setColor('#008b00') -- green
skill:setTooltip(baseValue .. ' +' .. (value - baseValue))
elseif value < baseValue then
widget:setColor('#b22222') -- red
skill:setTooltip(baseValue .. ' ' .. (value - baseValue))
else
widget:setColor('#c8c8aa') -- default
skill:removeTooltip()
end
end
function setSkillValue(id, value)
local skill = abilitiesWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
widget:setText(value)
end
function setSkillColor(id, value)
local skill = abilitiesWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
widget:setColor(value)
end
function setSkillTooltip(id, value)
local skill = abilitiesWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
widget:setTooltip(value)
end
function setSkillPercent(id, percent, tooltip)
local skill = abilitiesWindow:recursiveGetChildById(id)
local widget = skill:getChildById('percent')
if widget then
widget:setPercent(math.floor(percent))
if tooltip then
widget:setTooltip(tooltip)
end
end
end
function checkAlert(id, value, maxValue, threshold, greaterThan)
if greaterThan == nil then greaterThan = false end
local alert = false
-- maxValue can be set to false to check value and threshold
-- used for regeneration checking
if type(maxValue) == 'boolean' then
if maxValue then
return
end
if greaterThan then
if value > threshold then
alert = true
end
else
if value < threshold then
alert = true
end
end
elseif type(maxValue) == 'number' then
if maxValue < 0 then
return
end
local percent = math.floor((value / maxValue) * 100)
if greaterThan then
if percent > threshold then
alert = true
end
else
if percent < threshold then
alert = true
end
end
end
if alert then
setSkillColor(id, '#b22222') -- red
else
resetSkillColor(id)
end
end
function update()
end
function refresh()
local player = g_game.getLocalPlayer()
if not player then return end
if expSpeedEvent then expSpeedEvent:cancel() end
expSpeedEvent = cycleEvent(checkExpSpeed, 30*1000)
onExperienceChange(player, player:getExperience())
onLevelChange(player, player:getLevel(), player:getLevelPercent())
onHealthChange(player, player:getHealth(), player:getMaxHealth())
onManaChange(player, player:getMana(), player:getMaxMana())
onMagicLevelChange(player, player:getMagicLevel(), player:getMagicLevelPercent())
local hasAdditionalSkills = g_game.getFeature(GameAdditionalSkills)
for i = Skill.Sword, Skill.Fishing do
onSkillChange(player, i, player:getSkillLevel(i), player:getSkillLevelPercent(i))
onBaseSkillChange(player, i, player:getSkillBaseLevel(i))
if i > Skill.Fishing then
toggleSkill('skillId'..i, hasAdditionalSkills)
end
end
update()
local contentsPanel = abilitiesWindow:getChildById('contentsPanel')
abilitiesWindow:setContentMinimumHeight(108)
if hasAdditionalSkills then
abilitiesWindow:setContentMaximumHeight(480)
else
abilitiesWindow:setContentMaximumHeight(285)
local scrollbar = abilitiesWindow:getChildById('miniwindowScrollBar')
scrollbar:mergeStyle({ ['$!on'] = { }})
end
end
function offline()
if expSpeedEvent then expSpeedEvent:cancel() expSpeedEvent = nil end
end
function checkExpSpeed()
local player = g_game.getLocalPlayer()
if not player then return end
local currentExp = player:getExperience()
local currentTime = g_clock.seconds()
if player.lastExps ~= nil then
player.expSpeed = (currentExp - player.lastExps[1][1])/(currentTime - player.lastExps[1][2])
onLevelChange(player, player:getLevel(), player:getLevelPercent())
else
player.lastExps = {}
end
table.insert(player.lastExps, {currentExp, currentTime})
if #player.lastExps > 30 then
table.remove(player.lastExps, 1)
end
end
function onSkillButtonClick(button)
local percentBar = button:getChildById('percent')
if percentBar then
percentBar:setVisible(not percentBar:isVisible())
if percentBar:isVisible() then
button:setHeight(21)
else
button:setHeight(21 - 6)
end
end
end
function onHealthChange(localPlayer, health, maxHealth)
setSkillValue('health', health)
checkAlert('health', health, maxHealth, 30)
healthBar:setValue(health, 0, maxHealth)
end
function onManaChange(localPlayer, mana, maxMana)
setSkillValue('mana', mana)
checkAlert('mana', mana, maxMana, 30)
manaBar:setValue(mana, 0, maxMana)
end
function onLevelChange(localPlayer, value, percent)
experienceBar:setTooltip(tr(experienceTooltip, percent, value+1))
experienceBar:setPercent(percent)
end
function onExperienceChange(localPlayer, value)
setSkillValue('experience', value)
end
function setExperienceTooltip(tooltip)
experienceTooltip = tooltip
local localPlayer = g_game.getLocalPlayer()
if localPlayer then
experienceBar:setTooltip(tr(experienceTooltip, localPlayer:getLevelPercent(), localPlayer:getLevel()+1))
end
end
function onMagicLevelChange(localPlayer, magiclevel, percent)
setSkillValue('magiclevel', magiclevel)
setSkillPercent('magiclevel', percent, tr(magiclevelTooltip, 100 - percent))
onBaseMagicLevelChange(localPlayer, localPlayer:getBaseMagicLevel())
end
function onBaseMagicLevelChange(localPlayer, baseMagicLevel)
setSkillBase('magiclevel', localPlayer:getMagicLevel(), baseMagicLevel)
end
function onSkillChange(localPlayer, id, level, percent)
setSkillValue('skillId' .. id, level)
setSkillPercent('skillId' .. id, percent, tr(skillTooltip, 100 - percent))
onBaseSkillChange(localPlayer, id, localPlayer:getSkillBaseLevel(id))
end
function onBaseSkillChange(localPlayer, id, baseLevel)
setSkillBase('skillId'..id, localPlayer:getSkillLevel(id), baseLevel)
end
function getAbilities()
return abilitiesWindow
end
function addTab(name, panel, icon)
abilitiesTabBar:addTab(name, panel, icon)
end
function addButton(name, func, icon)
abilitiesTabBar:addButton(name, func, icon)
end