• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

game healthinfo

Gubailovo

Well-Known Member
Joined
Dec 19, 2013
Messages
407
Solutions
2
Reaction score
62
for a long time I tried to figure it out, but to no avail.
could you help me with that?
I need to change the display of fishing skill to display mana.
and exchange experience with mana.

life
mana
an experience
stamina
Скриншот 11-09-2021 115200.jpg

Lua:
Icons = {}
Icons[1] = { tooltip = tr('You are poisoned'), path = '/game_healthinfo/icons/poisoned.png', id = 'condition_poisoned' }
Icons[2] = { tooltip = tr('You are burning'), path = '/game_healthinfo/icons/burning.png', id = 'condition_burning' }
Icons[4] = { tooltip = tr('You are electrified'), path = '/game_healthinfo/icons/electrified.png', id = 'condition_electrified' }
Icons[8] = { tooltip = tr('You are drunk'), path = '/game_healthinfo/icons/drunk.png', id = 'condition_drunk' }
Icons[16] = { tooltip = tr('You are protected by a magic shield'), path = '/game_healthinfo/icons/magic_shield.png', id = 'condition_magic_shield' }
Icons[32] = { tooltip = tr('You are paralysed'), path = '/game_healthinfo/icons/slowed.png', id = 'condition_slowed' }
Icons[64] = { tooltip = tr('You are hasted'), path = '/game_healthinfo/icons/haste.png', id = 'condition_haste' }
Icons[128] = { tooltip = tr('You may not logout during a fight'), path = '/game_healthinfo/icons/logout_block.png', id = 'condition_logout_block' }
Icons[256] = { tooltip = tr('You are drowing'), path = '/game_healthinfo/icons/drowning.png', id = 'condition_drowning' }
Icons[512] = { tooltip = tr('You are freezing'), path = '/game_healthinfo/icons/freezing.png', id = 'condition_freezing' }
Icons[1024] = { tooltip = tr('You are dazzled'), path = '/game_healthinfo/icons/dazzled.png', id = 'condition_dazzled' }
Icons[2048] = { tooltip = tr('You are cursed'), path = '/game_healthinfo/icons/cursed.png', id = 'condition_cursed' }
Icons[4096] = { tooltip = tr('Você está strengthened'), path = '/game_healthinfo/icons/strengthened.png', id = 'condition_strengthened' }
Icons[8192] = { tooltip = tr('You may not logout or enter a protection zone'), path = '/game_healthinfo/icons/protection_zone_block.png', id = 'condition_protection_zone_block' }
Icons[16384] = { tooltip = tr('You are within a protection zone'), path = '/game_healthinfo/icons/protection_zone.png', id = 'condition_protection_zone' }
Icons[32768] = { tooltip = tr('You are bleeding'), path = '/game_healthinfo/icons/bleeding.png', id = 'condition_bleeding' }
Icons[65536] = { tooltip = tr('You are hungry'), path = '/game_healthinfo/icons/hungry.png', id = 'condition_hungry' }

healthInfoWindow = nil
nameLabel = nil
outfitBox = nil
healthBar = nil
healthLabel = nil
levelLabel = nil
manaBar = nil
experienceBar = nil
experienceLabel = nil
fishBar = nil
fishLabel = nil
pokeballBar = nil
winnerLabel = nil
capLabel = nil
stmBar = nil

function init()
    connect(g_game, { onGameEnd   = offline, onGameStart = refresh })
    connect(LocalPlayer, { onHealthChange = onHealthChange,
                           onManaChange = onManaChange,
                           onStatesChange = onStatesChange,
                           onLevelChange = onLevelChange,
                           onFreeCapacityChange = onFreeCapacityChange,
                           onStaminaChange = onStaminaChange,
                           onSkillChange = onSkillChange })
    
    healthInfoWindow = g_ui.displayUI('health.otui')
    healthInfoWindow:hide()
    
    healthInfoButton = modules.client_topmenu.addRightGameToggleButton('healthInfoButton', tr('Health Information'), '/images/topbuttons/healthinfo', toggle)
    
    nameLabel   = healthInfoWindow:getChildById('nameLabel')
    outfitBox   = healthInfoWindow:getChildById('outfitBox')
    levelLabel  = healthInfoWindow:getChildById('levelLabel')
    healthBar   = healthInfoWindow:getChildById('healthBar')
    healthLabel = healthInfoWindow:getChildById('healthLabel')
    manathBar   = healthInfoWindow:getChildById('manathBar')
    manaLabel = healthInfoWindow:getChildById('manaLabel')
    experienceBar   = healthInfoWindow:getChildById('experienceBar')
    experienceLabel = healthInfoWindow:getChildById('experienceLabel')
    fishBar   = healthInfoWindow:getChildById('fishBar')
    fishLabel = healthInfoWindow:getChildById('fishLabel')
    capLabel  = healthInfoWindow:getChildById('capLabel')
    pokeballBar = healthInfoWindow:getChildById('pokeballBar')
    winnerLabel = healthInfoWindow:getChildById('winnerLabel')   
    stmBar = healthInfoWindow:getChildById('stmBar')
    
    if g_game.isOnline() then
        onStatesChange(g_game.getLocalPlayer(), g_game.getLocalPlayer():getStates(), 0)
    end
    
    refresh()
end

function terminate()
    disconnect(g_game, { onGameEnd   = offline, onGameStart = refresh })
    disconnect(LocalPlayer, { onHealthChange = onHealthChange,
                              onManaChange = onManaChange,
                              onStatesChange = onStatesChange,
                              onLevelChange = onLevelChange,
                              onFreeCapacityChange = onFreeCapacityChange,
                              onStaminaChange = onStaminaChange,
                              onSkillChange = onSkillChange })
    healthInfoWindow:destroy()
    healthInfoButton:destroy()
end

function toggle()
  if healthInfoWindow:isVisible() then
    healthInfoWindow:hide()
  else
    healthInfoWindow:show()
    refresh()
  end
end

function offline()
    healthInfoWindow:hide()
    healthInfoWindow:recursiveGetChildById('panelCondition'):destroyChildren()
end

function refresh()
    if g_game.isOnline() then
        local localPlayer = g_game.getLocalPlayer()
        nameLabel:setText(localPlayer:getName())
        outfitBox:setOutfit(localPlayer:getOutfit())
        onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
        onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
        onLevelChange(localPlayer, localPlayer:getLevel(), localPlayer:getLevelPercent())
        onFreeCapacityChange(localPlayer, localPlayer:getFreeCapacity())   
        onStaminaChange(localPlayer, localPlayer:getStamina())       
        onSkillChange(localPlayer, 2, localPlayer:getSkillLevel(2), localPlayer:getSkillLevelPercent(2),true)
        onSkillChange(localPlayer, 6, localPlayer:getSkillLevel(6), localPlayer:getSkillLevelPercent(6), true)
    end
end

function setOutfitBox(outfit)
    outfitBox:setOutfit(outfit)
end

function onHealthChange(localPlayer, health, maxHealth)
  healthBar:setValue(health, 0, maxHealth)
  healthLabel:setText(math.floor(health / maxHealth * 100).."%")
end

function onManaChange(localPlayer, mana, maxMana)
  manaBar:setValue(mana, 0, maxMana)
  manathLabel:setText(math.floor(mana / maxMana * 100).."%")
end

function onLevelChange(localPlayer, value, percent)
  levelLabel:setText('Lv'..localPlayer:getLevel())
  experienceLabel:setText(percent.. "%")
  experienceBar:setPercent(percent)
end

function onFreeCapacityChange(localPlayer, freeCapacity)
  capLabel:setText(freeCapacity)
end

function onSkillChange(localPlayer, id, level, percent, hur)
    if id == 2 then
        winnerLabel:setText(level)
        winnerLabel:setTooltip('Vitorias: '..level)
    end
    if id == 6 then
        fishBar:setPercent(percent)
        fishBar:setTooltip(tr("Fishing: "..level))
        fishLabel:setText(percent.."%")
    end
end


function onStatesChange(localPlayer, now, old)
  if now == old then return end
  local bitsChanged = bit32.bxor(now, old)
  for i = 1, 32 do
    local pow = math.pow(2, i-1)
    if pow > bitsChanged then break end
    local bitChanged = bit32.band(bitsChanged, pow)
    if bitChanged ~= 0 then
      toggleIcon(bitChanged)
    end
  end
end

function toggleIcon(bitChanged)
  local content = healthInfoWindow:recursiveGetChildById('panelCondition')

  local icon = content:getChildById(Icons[bitChanged].id)
  if icon then
    icon:destroy()
  else
    icon = g_ui.createWidget('ConditionWidget', content)
    icon:setId(Icons[bitChanged].id)
    icon:setImageSource(Icons[bitChanged].path)
    icon:setTooltip(Icons[bitChanged].tooltip)
  end
end

XML:
HealthBar < ProgressBar
  background-color: #00e100
  size: 120 10
  image-color: alpha
  icon: img/hp
  icon-align: right
  icon-offset: 1 0
  border-width: 0
  margin: 5 0 0 30

ExperienceBar < ProgressBar
  background-color: #18b1f9
  size: 105 5
  image-color: alpha
  icon: img/exp
  icon-align: right
  icon-offset: 1 0
  border-width: 0
  margin: 6 0 0 30

FishBar < ProgressBar
  background-color: #6b6dc7
  size: 110 5
  image-color: alpha
  icon: img/mana
  icon-align: right
  icon-offset: 1 0
  border-width: 0
  margin: 7 0 0 27

StmBar < ProgressBar
  background-color: #e56c00
  size: 87 5
  image-color: alpha
  icon: img/stm
  icon-align: right
  icon-offset: 1 0
  border-width: 0
  margin: 7 0 0 32

PokeballBar < UIWidget
  size: 8 1
  image-source: img/pokeball0
  margin: 8 0 0 -13

Slot < UIWidget
  image-source: img/slot
  font: terminus-10px
  color: #e8c05e
  margin-left: 2
  icon-align: left

SoulLabel < GameLabel
  id: soulLabel
  text-align: right
  color: white
  font: verdana-11px-rounded
  anchors.bottom: parent.bottom
  anchors.right: parent.right
  anchors.left: parent.horizontalCenter
  margin-top: 5
  margin-right: 3
  on: true

  $!on:
    visible: false
    margin-top: 0
    height: 0

ConditionWidget < UIWidget
  size: 18 18

  $!first:
    margin-left: 2

HeadlessWindow
  id: healthInfoWindow
  size: 253 103
  image-source: img/healthinfo

  Label
    id: nameLabel
    anchors.top: parent.top
    anchors.left: parent.left
    text-auto-resize: true
    color: #e8c05e
    margin: -5 0 0 65

  UICreature
    id: outfitBox
    size: 50 50
    anchors.top: parent.top
    anchors.left: parent.left
    margin: 9 0 0 10

  Slot
    id: levelLabel
    anchors.bottom: parent.bottom
    anchors.left: parent.left
    image-color: #4f707b
    margin: 0 0 10 13

  HealthBar
    id: healthBar
    anchors.top: nameLabel.bottom
    anchors.left: outfitBox.right

  Label
    id: healthLabel
    font: terminus-10px
    anchors.top: prev.top
    anchors.left: prev.right
    margin: -2 0 0 8

  ExperienceBar
    id: experienceBar
    anchors.top: healthBar.bottom
    anchors.left: outfitBox.right

  Label
    id: experienceLabel
    font: terminus-10px
    anchors.top: prev.top
    anchors.left: prev.right
    margin: -3 0 0 7

  FishBar
    id: fishBar
    anchors.top: experienceBar.bottom
    anchors.left: outfitBox.right

  Label
    id: fishLabel
    font: terminus-10px
    anchors.top: prev.top
    anchors.left: prev.right
    margin: -3 0 0 5
    text: 100%

  StmBar
    id: stmBar
    anchors.top: fishBar.bottom
    anchors.left: outfitBox.right

  PokeballBar
    id: pokeballBar
    anchors.top: prev.bottom
    anchors.left: fishBar.left

  Slot
    id: capLabel
    width: 60
    anchors.top: prev.top
    anchors.left: prev.right
    icon: img/backpack

  Panel
    id: panelCondition
    layout:
      type: horizontalBox
    height: 22
    padding: 2
    margin-top: 2
    anchors.top: prev.bottom
    anchors.left: winnerLabel.left
    anchors.right: parent.right


thanks in advance
 
Back
Top