Ir para conteúdo
  • 0

Erro script inventory in healthinfo


Noninhouh

Pergunta

Eu tava querendo fazer o healthinfo igual a do pxg, e consegui, mas qd eu troco de character, se não tiver nenhum poke no slot, aparece o poke que tava no slot do outro character, deu pra intende?

script inventory in healthinfo .lua:

 

Icons = {}

Icons[1] = { tooltip = tr('You are poisoned'), path = '/images/game/states/poisoned', id = 'condition_poisoned' }

Icons[2] = { tooltip = tr('You are burning'), path = '/images/game/states/burning', id = 'condition_burning' }

Icons[4] = { tooltip = tr('You are electrified'), path = '/images/game/states/electrified', id = 'condition_electrified' }

Icons[8] = { tooltip = tr('You are drunk'), path = '/images/game/states/drunk', id = 'condition_drunk' }

Icons[16] = { tooltip = tr('You are protected by a magic shield'), path = '/images/game/states/magic_shield', id = 'condition_magic_shield' }

Icons[32] = { tooltip = tr('You are paralysed'), path = '/images/game/states/slowed', id = 'condition_slowed' }

Icons[64] = { tooltip = tr('You are hasted'), path = '/images/game/states/haste', id = 'condition_haste' }

Icons[128] = { tooltip = tr('You may not logout during a fight'), path = '/images/game/states/logout_block', id = 'condition_logout_block' }

Icons[256] = { tooltip = tr('You are drowning'), path = '/images/game/states/drowning', id = 'condition_drowning' }

Icons[512] = { tooltip = tr('You are freezing'), path = '/images/game/states/freezing', id = 'condition_freezing' }

Icons[1024] = { tooltip = tr('You are dazzled'), path = '/images/game/states/dazzled', id = 'condition_dazzled' }

Icons[2048] = { tooltip = tr('You are cursed'), path = '/images/game/states/cursed', id = 'condition_cursed' }

Icons[4096] = { tooltip = tr('You are strengthened'), path = '/images/game/states/strengthened', id = 'condition_strengthened' }

Icons[8192] = { tooltip = tr('You may not logout or enter a protection zone'), path = '/images/game/states/protection_zone_block', id = 'condition_protection_zone_block' }

Icons[16384] = { tooltip = tr('You are within a protection zone'), path = '/images/game/states/protection_zone', id = 'condition_protection_zone' }

Icons[32768] = { tooltip = tr('You are bleeding'), path = '/images/game/states/bleeding', id = 'condition_bleeding' }

Icons[65536] = { tooltip = tr('You are hungry'), path = '/images/game/states/hungry', id = 'condition_hungry' }

 

InventorySlotStyles = {

[inventorySlotBody] = "BodySlot",

[inventorySlotLeg] = "LegSlot",

[inventorySlotFeet] = "FeetSlot",

[inventorySlotFinger] = "FingerSlot",

}

 

healthInfoWindow = nil

inventoryPanel = nil

healthBar = nil

manaBar = nil

experienceBar = nil

healthTooltip = 'Your character health is %d out of %d.'

manaTooltip = 'Your character mana is %d out of %d.'

experienceTooltip = 'You have %d%% to advance to level %d.'

 

function init()

connect(LocalPlayer, { onInventoryChange = onInventoryChange,

onHealthChange = onHealthChange,

onManaChange = onManaChange,

onLevelChange = onLevelChange,

onStatesChange = onStatesChange })

 

connect(g_game, { onGameEnd = offline })

 

healthInfoButton = modules.client_topmenu.addRightGameToggleButton('healthInfoButton', tr('Health Information'), '/images/topbuttons/healthinfo', toggle)

healthInfoButton:setOn(true)

 

healthInfoWindow = g_ui.loadUI('healthinfo', modules.game_interface.getRightPanel())

healthInfoWindow:disableResize()

inventoryPanel = healthInfoWindow:getChildById('contentsPanel')

healthBar = healthInfoWindow:recursiveGetChildById('healthBar')

manaBar = healthInfoWindow:recursiveGetChildById('manaBar')

experienceBar = healthInfoWindow:recursiveGetChildById('experienceBar')

 

-- load condition icons

for k,v in pairs(Icons) do

g_textures.preload(v.path)

end

 

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())

onStatesChange(localPlayer, localPlayer:getStates(), 0)

end

 

healthInfoWindow:setup()

end

 

function terminate()

disconnect(LocalPlayer, { onHealthChange = onHealthChange,

onManaChange = onManaChange,

onLevelChange = onLevelChange,

onStatesChange = onStatesChange })

 

disconnect(g_game, { onGameEnd = offline })

 

healthInfoWindow:destroy()

healthInfoButton:destroy()

end

 

function toggle()

if healthInfoButton:isOn() then

healthInfoWindow:close()

healthInfoButton:setOn(false)

else

healthInfoWindow:open()

healthInfoButton:setOn(true)

end

end

 

function toggleIcon(bitChanged)

local content = healthInfoWindow:recursiveGetChildById('conditionPanel')

 

local icon = content:getChildById(Icons[bitChanged].id)

if icon then

icon:destroy()

else

icon = loadIcon(bitChanged)

icon:setParent(content)

end

end

 

function loadIcon(bitChanged)

local icon = g_ui.createWidget('ConditionWidget', content)

icon:setId(Icons[bitChanged].id)

icon:setImageSource(Icons[bitChanged].path)

icon:setTooltip(Icons[bitChanged].tooltip)

return icon

end

 

function offline()

healthInfoWindow:recursiveGetChildById('conditionPanel'):destroyChildren()

end

 

-- hooked events

function onMiniWindowClose()

healthInfoButton:setOn(false)

end

 

function onInventoryChange(player, slot, item, oldItem)

if slot >= InventorySlotPurse then return end

local itemWidget = inventoryPanel:getChildById('slot' .. slot)

if item then

itemWidget:setItem(item)

else

itemWidget:setStyle(InventorySlotStyles[slot])

itemWidget:setItem(nil)

end

end

 

function onHealthChange(localPlayer, health, maxHealth)

healthBar:setText(health .. ' / ' .. maxHealth)

healthBar:setTooltip(tr(healthTooltip, health, maxHealth))

healthBar:setValue(health, 0, maxHealth)

end

 

function onManaChange(localPlayer, mana, maxMana)

manaBar:setTooltip(tr(manaTooltip, mana, maxMana))

manaBar:setValue(mana, 0, maxMana)

end

 

function onLevelChange(localPlayer, value, percent)

experienceBar:setText(percent .. '%')

experienceBar:setTooltip(tr(experienceTooltip, percent, value+1))

experienceBar:setPercent(percent)

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

 

-- personalization functions

 

function hideExperience()

local removeHeight = experienceBar:getMarginRect().height

experienceBar:setOn(false)

healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight))

end

 

function setHealthTooltip(tooltip)

healthTooltip = tooltip

 

local localPlayer = g_game.getLocalPlayer()

if localPlayer then

healthBar:setTooltip(tr(healthTooltip, localPlayer:getHealth(), localPlayer:getMaxHealth()))

end

end

 

function setManaTooltip(tooltip)

manaTooltip = tooltip

 

local localPlayer = g_game.getLocalPlayer()

if localPlayer then

manaBar:setTooltip(tr(manaTooltip, localPlayer:getMana(), localPlayer:getMaxMana()))

end

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

 

 

Acho que precisa de algo pra qd o player entrar, atualizar os slots

script inventory:

 

InventorySlotStyles = {

[inventorySlotHead] = "HeadSlot",

[inventorySlotNeck] = "NeckSlot",

[inventorySlotBack] = "BackSlot",

[inventorySlotBody] = "BodySlot",

[inventorySlotRight] = "RightSlot",

[inventorySlotLeft] = "LeftSlot",

[inventorySlotLeg] = "LegSlot",

[inventorySlotFeet] = "FeetSlot",

[inventorySlotFinger] = "FingerSlot",

[inventorySlotAmmo] = "AmmoSlot"

}

 

inventoryWindow = nil

inventoryPanel = nil

inventoryButton = nil

 

function init()

connect(LocalPlayer, { onInventoryChange = onInventoryChange })

connect(g_game, { onGameStart = refresh })

 

g_keyboard.bindKeyDown('Ctrl+I', toggle)

 

inventoryButton = modules.client_topmenu.addRightGameToggleButton('inventoryButton', tr('Inventory') .. ' (Ctrl+I)', '/images/topbuttons/inventory', toggle)

inventoryButton:setOn(true)

 

inventoryWindow = g_ui.loadUI('inventory', modules.game_interface.getRightPanel())

inventoryWindow:disableResize()

inventoryPanel = inventoryWindow:getChildById('contentsPanel')

 

refresh()

inventoryWindow:setup()

end

 

function terminate()

disconnect(LocalPlayer, { onInventoryChange = onInventoryChange })

disconnect(g_game, { onGameStart = refresh })

 

g_keyboard.unbindKeyDown('Ctrl+I')

 

inventoryWindow:destroy()

inventoryButton:destroy()

end

 

function refresh()

local player = g_game.getLocalPlayer()

for i=InventorySlotFirst,InventorySlotLast do

if g_game.isOnline() then

onInventoryChange(player, i, player:getInventoryItem(i))

else

onInventoryChange(player, i, nil)

end

end

end

 

function toggle()

g_game.useInventoryItem(2853)

end

 

function onMiniWindowClose()

inventoryButton:setOn(false)

end

 

-- hooked events

function onInventoryChange(player, slot, item, oldItem)

if slot >= InventorySlotPurse then return end

local itemWidget = inventoryPanel:getChildById('slot' .. slot)

if item then

itemWidget:setStyle('Item')

itemWidget:setItem(item)

else

itemWidget:setStyle(InventorySlotStyles[slot])

itemWidget:setItem(nil)

end

end

 

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

×
×
  • Criar Novo...