tibia-client/modules/game_inventory/inventory.lua

38 lines
965 B
Lua
Raw Normal View History

2011-11-10 06:29:25 +01:00
Inventory = {}
-- private variables
local window = nil
-- public functions
function Inventory.create()
window = displayUI('inventory.otui', { parent = Game.gameRightPanel })
2011-11-10 06:29:25 +01:00
end
function Inventory.destroy()
window:destroy()
window = nil
end
-- hooked events
function Inventory.onInventoryChange(slot, item)
2012-01-03 01:10:39 +01:00
local itemWidget = window:getChildById('slot' .. slot)
2011-11-10 06:29:25 +01:00
itemWidget:setItem(item)
end
function Inventory.onFreeCapacityChange(freeCapacity)
local widget = window:getChildById('capacity')
widget:setText("Cap:\n" .. freeCapacity)
end
function Inventory.onSoulChange(soul)
local widget = window:getChildById('soul')
widget:setText("Soul:\n" .. soul)
end
2011-11-10 06:29:25 +01:00
connect(Game, { onLogin = Inventory.create,
onLogout = Inventory.destroy,
onInventoryChange = Inventory.onInventoryChange,
onFreeCapacityChange = Inventory.onFreeCapacityChange,
onSoulChange = Inventory.onSoulChange })
2012-01-09 21:54:37 +01:00