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!!
This is my Panel and is not scrolling, I think it's because the scroll can't find the Panel. Somebody can help me fix this ?
abilities.lua
abilities.otui
skills.otui
I got this error on my OtClient Terminal
I need the help of you who understand this better than me!!
This is my Panel and is not scrolling, I think it's because the scroll can't find the Panel. Somebody can help me fix this ?
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('contentsPanel'))
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
abilities.otui
CSS:
MiniWindow
id: abilitiesWindow
height: 50
!text: tr('Abilities')
InsideWindow
id: InsideWindow2
image-border: 2
size: 132 20
anchors.top: parent.top
anchors.left: parent.left
margin-left: 8
margin-top: 25
TabBarVerticalHabilidades
id: abilitiesTabBar
size: 30 18
anchors.top: InsideWindow2.top
anchors.left: InsideWindow2.left
anchors.right: InsideWindow2.right
margin-top: 1
margin-left: 1
margin-right: 1
Panel
id: contentsPanel
anchors.top: abilitiesTabBar.bottom
anchors.bottom: parent.bottom
anchors.left: abilitiesTabBar.left
anchors.right: abilitiesTabBar.right
margin-top: 9
margin-bottom: 10
margin-left: -1
skills.otui
CSS:
HorizontalSeparator < UIWidget
image-source: /images/ui/separator_horizontal
image-border: 1
height: 2
phantom: true
focusable: false
HealthBar < ProgressBar
ManaBar < ProgressBar
ExperienceBar < ProgressBar
margin-top: -6
SkillFirstWidget < UIWidget
SkillButton < UIButton
height: 15
margin-bottom: 2
&onClick: onSkillButtonClick
SmallSkillButton < SkillButton
height: 14
SkillNameLabel < GameLabel
font: verdana-11px-rounded
color: #c8c8aa
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
SkillValueLabel < GameLabel
id: value
font: verdana-11px-rounded
color: #c8c8aa
text-align: topright
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: prev.left
SkillPercentPanel < ProgressBar
id: percent
background-color: #007800
height: 5
margin-top: 15
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
phantom: false
Panel
InsideWindow
id: insideWindow
image-border: 3
padding-left: 5
padding-right: 5
padding-top: 5
margin-bottom: 7
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
MiniWindowContents
id: contentsPanel
anchors.top: insideWindow.top
anchors.bottom: parent.bottom
anchors.left: insideWindow.left
anchors.right: insideWindow.right
margin-top: 5
margin-bottom: 5
margin-left: 5
margin-right: 5
layout: verticalBox
SkillButton
id: health
height: 11
SkillNameLabel
!text: tr('Health')
margin-top: -1
SkillValueLabel
margin-top: -1
HealthBar
id: healthBar
size: 120 5
background-color: #AA0000
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
SkillButton
id: mana
height: 11
SkillNameLabel
!text: tr('Mana')
margin-top: -1
SkillValueLabel
margin-top: -1
margin-top: 5
ManaBar
id: manaBar
size: 120 5
background-color: #0000AA
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
SkillButton
id: level
SkillNameLabel
!text: tr('Level')
margin-top: -1
SkillValueLabel
margin-top: 5
SkillButton
id: experience
SkillNameLabel
!text: tr('Experience')
margin-top: -3
SkillValueLabel
margin-top: -3
ExperienceBar
id: experienceBar
size: 120 5
background-color: #007800
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
Label
height: 5
margin-top: 8
HorizontalSeparator
id: HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
SkillButton
id: magiclevel
SkillNameLabel
!text: tr('Magic Level')
SkillValueLabel
color: red
SkillPercentPanel
background-color: #007800
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
SkillButton
id: skillId0
SkillNameLabel
!text: tr('Fist Fighting')
SkillValueLabel
SkillPercentPanel
visible: false
SkillButton
id: skillId1
SkillNameLabel
!text: tr('Club Fighting')
SkillValueLabel
SkillPercentPanel
visible: false
SkillButton
id: skillId2
SkillNameLabel
!text: tr('Melee')
SkillValueLabel
SkillPercentPanel
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
SkillButton
id: skillId3
SkillNameLabel
!text: tr('Axe Fighting')
SkillValueLabel
SkillPercentPanel
visible: false
SkillButton
id: skillId4
SkillNameLabel
!text: tr('Distance')
SkillValueLabel
SkillPercentPanel
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
SkillButton
id: skillId5
SkillNameLabel
!text: tr('Defending')
SkillValueLabel
SkillPercentPanel
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
Label
margin-top: 2
HorizontalSeparator
id: HorizontalSeparator
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
SkillButton
id: skillId6
margin-top: -8
SkillNameLabel
!text: tr('Fishing')
SkillValueLabel
SkillPercentPanel
InsideWindow
size: 120 5
image-border: 3
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
SmallSkillButton
id: skillId7
SkillNameLabel
!text: tr('Critical Hit Chance')
SkillValueLabel
visible: false
SmallSkillButton
id: skillId8
SkillNameLabel
!text: tr('Critical Hit Damage')
SkillValueLabel
visible: false
SmallSkillButton
id: skillId9
SkillNameLabel
!text: tr('Life Leech Chance')
SkillValueLabel
visible: false
SmallSkillButton
id: skillId10
SkillNameLabel
!text: tr('Life Leech Amount')
SkillValueLabel
visible: false
SmallSkillButton
id: skillId11
SkillNameLabel
!text: tr('Life Leech Chance')
SkillValueLabel
visible: false
SmallSkillButton
id: skillId12
SkillNameLabel
!text: tr('Life Leech Amount')
SkillValueLabel
visible: false
I got this error on my OtClient Terminal
Code:
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>