Helliot1
Owner of Empire Online
- Joined
- Jul 26, 2017
- Messages
- 315
- Solutions
- 1
- Reaction score
- 58
Hello, had months that I'm trying to add 2 new slots to my client, I urgently need help.
I don't know what I'm doing wrong.
If anyone can help me, I'll be very grateful. Because this is so hard.
This is my Inventory.lua
Inventory.otui
Player.lua
I'm going crazy, because I do not see any error in them.
When I enter in my client, don't show the Inventory
and in the Terminal, show this error
Thanks!!
CAN DELETE THIS THREAD. I FINNALY GET FIX IT!!!
It was some lines (spaces) that I have to delete to make it work
I don't know what I'm doing wrong.
If anyone can help me, I'll be very grateful. Because this is so hard.
This is my Inventory.lua
Lua:
InventorySlotStyles = {
[InventorySlotHead] = "HeadSlot",
[InventorySlotNeck] = "NeckSlot",
[InventorySlotBack] = "BackSlot",
[InventorySlotBody] = "BodySlot",
[InventorySlotRight] = "RightSlot",
[InventorySlotLeft] = "LeftSlot",
[InventorySlotLeg] = "LegSlot",
[InventorySlotFeet] = "FeetSlot",
[InventorySlotFinger] = "FingerSlot",
[InventorySlotAmmo] = "AmmoSlot",
[InventorySlotBracers] = "BracersSlot",
[InventorySlotGauntlets] = "GauntletsSlot"
}
inventoryWindow = nil
inventoryPanel = nil
inventoryButton = nil
purseButton = nil
function init()
connect(LocalPlayer, {
onInventoryChange = onInventoryChange,
onBlessingsChange = onBlessingsChange
})
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')
purseButton = inventoryPanel:getChildById('purseButton')
local function purseFunction()
local purse = g_game.getLocalPlayer():getInventoryItem(InventorySlotPurse)
if purse then
g_game.use(purse)
end
end
purseButton.onClick = purseFunction
refresh()
inventoryWindow:setup()
end
function terminate()
disconnect(LocalPlayer, {
onInventoryChange = onInventoryChange,
onBlessingsChange = onBlessingsChange
})
disconnect(g_game, { onGameStart = refresh })
g_keyboard.unbindKeyDown('Ctrl+I')
inventoryWindow:destroy()
inventoryButton:destroy()
end
function toggleAdventurerStyle(hasBlessing)
for slot = InventorySlotFirst, InventorySlotLast do
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if itemWidget then
itemWidget:setOn(hasBlessing)
end
end
end
function refresh()
local player = g_game.getLocalPlayer()
for i = InventorySlotFirst, InventorySlotPurse do
if g_game.isOnline() then
onInventoryChange(player, i, player:getInventoryItem(i))
else
onInventoryChange(player, i, nil)
end
toggleAdventurerStyle(player and Bit.hasBit(player:getBlessings(), Blessings.Adventurer) or false)
end
purseButton:setVisible(g_game.getFeature(GamePurseSlot))
end
function toggle()
if inventoryButton:isOn() then
inventoryWindow:close()
inventoryButton:setOn(false)
else
inventoryWindow:open()
inventoryButton:setOn(true)
end
end
function onMiniWindowClose()
inventoryButton:setOn(false)
end
-- hooked events
function onInventoryChange(player, slot, item, oldItem)
if slot > InventorySlotPurse then return end
if slot == InventorySlotPurse then
if g_game.getFeature(GamePurseSlot) then
purseButton:setEnabled(item and true or false)
end
return
end
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if item then
itemWidget:setStyle('InventoryItem')
itemWidget:setItem(item)
else
itemWidget:setStyle(InventorySlotStyles[slot])
itemWidget:setItem(nil)
end
end
function onBlessingsChange(player, blessings, oldBlessings)
local hasAdventurerBlessing = Bit.hasBit(blessings, Blessings.Adventurer)
if hasAdventurerBlessing ~= Bit.hasBit(oldBlessings, Blessings.Adventurer) then
toggleAdventurerStyle(hasAdventurerBlessing)
end
end
Inventory.otui
Lua:
InventoryItem < Item
$on:
image-source: /images/ui/item-blessed
HeadSlot < InventoryItem
id: slot1
image-source: /images/game/slots/head
&position: {x=65535, y=1, z=0}
$on:
image-source: /images/game/slots/head-blessed
BodySlot < InventoryItem
id: slot4
image-source: /images/game/slots/body
&position: {x=65535, y=4, z=0}
$on:
image-source: /images/game/slots/body-blessed
LegSlot < InventoryItem
id: slot7
image-source: /images/game/slots/legs
&position: {x=65535, y=7, z=0}
$on:
image-source: /images/game/slots/legs-blessed
FeetSlot < InventoryItem
id: slot8
image-source: /images/game/slots/feet
&position: {x=65535, y=8, z=0}
$on:
image-source: /images/game/slots/feet-blessed
NeckSlot < InventoryItem
id: slot2
image-source: /images/game/slots/neck
&position: {x=65535, y=2, z=0}
$on:
image-source: /images/game/slots/neck-blessed
LeftSlot < InventoryItem
id: slot6
image-source: /images/game/slots/left-hand
&position: {x=65535, y=6, z=0}
$on:
image-source: /images/game/slots/left-hand-blessed
FingerSlot < InventoryItem
id: slot9
image-source: /images/game/slots/finger
&position: {x=65535, y=9, z=0}
$on:
image-source: /images/game/slots/finger-blessed
BracersSlot < InventoryItem
id: slot11
image-source: /images/game/slots/bracers
&position: {x=65535, y=11, z=0}
$on:
image-source: /images/game/slots/bracers-blessed
BackSlot < InventoryItem
id: slot3
image-source: /images/game/slots/back
&position: {x=65535, y=3, z=0}
$on:
image-source: /images/game/slots/back-blessed
RightSlot < InventoryItem
id: slot5
image-source: /images/game/slots/right-hand
&position: {x=65535, y=5, z=0}
$on:
image-source: /images/game/slots/right-hand-blessed
AmmoSlot < InventoryItem
id: slot10
image-source: /images/game/slots/ammo
&position: {x=65535, y=10, z=0}
$on:
image-source: /images/game/slots/ammo-blessed
GauntletsSlot < InventoryItem
id: slot12
image-source: /images/game/slots/gauntlets
&position: {x=65535, y=12, z=0}
$on:
image-source: /images/game/slots/gauntlets-blessed
PurseButton < Button
id: purseButton
size: 26 26
!tooltip: tr('Open purse')
icon-source: /images/game/slots/purse
icon-size: 24 24
icon-offset: 1 1
MiniWindow
id: inventoryWindow
!text: tr('Inventory')
icon: /images/topbuttons/inventory
height: 200
@onClose: modules.game_inventory.onMiniWindowClose()
&save: true
MiniWindowContents
HeadSlot
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
margin-top: 3
BodySlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
LegSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
FeetSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
NeckSlot
anchors.top: slot1.top
anchors.right: slot1.left
margin-top: 0
margin-right: 5
LeftSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
FingerSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
BracersSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
BackSlot
anchors.top: slot1.top
anchors.left: slot1.right
margin-top: 0
margin-left: 5
RightSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
AmmoSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
GauntletsSlot
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
margin-top: 3
PurseButton
margin-top: 3
anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter
Player.lua
Lua:
-- @docclass Player
PlayerStates = {
None = 0,
Poison = 1,
Burn = 2,
Energy = 4,
Drunk = 8,
ManaShield = 16,
Paralyze = 32,
Haste = 64,
Swords = 128,
Drowning = 256,
Freezing = 512,
Dazzled = 1024,
Cursed = 2048,
PartyBuff = 4096,
PzBlock = 8192,
Pz = 16384,
Bleeding = 32768,
Hungry = 65536
}
InventorySlotOther = 0
InventorySlotHead = 1
InventorySlotNeck = 2
InventorySlotBack = 3
InventorySlotBody = 4
InventorySlotRight = 5
InventorySlotLeft = 6
InventorySlotLeg = 7
InventorySlotFeet = 8
InventorySlotFinger = 9
InventorySlotAmmo = 10
InventorySlotBracers = 11
InventorySlotGauntlets = 12
InventorySlotPurse = 13
InventorySlotFirst = InventorySlotHead
InventorySlotLast = InventorySlotPurse
function Player:isPartyLeader()
local shield = self:getShield()
return (shield == ShieldWhiteYellow or
shield == ShieldYellow or
shield == ShieldYellowSharedExp or
shield == ShieldYellowNoSharedExpBlink or
shield == ShieldYellowNoSharedExp)
end
function Player:isPartyMember()
local shield = self:getShield()
return (shield == ShieldWhiteYellow or
shield == ShieldYellow or
shield == ShieldYellowSharedExp or
shield == ShieldYellowNoSharedExpBlink or
shield == ShieldYellowNoSharedExp or
shield == ShieldBlueSharedExp or
shield == ShieldBlueNoSharedExpBlink or
shield == ShieldBlueNoSharedExp or
shield == ShieldBlue)
end
function Player:isPartySharedExperienceActive()
local shield = self:getShield()
return (shield == ShieldYellowSharedExp or
shield == ShieldYellowNoSharedExpBlink or
shield == ShieldYellowNoSharedExp or
shield == ShieldBlueSharedExp or
shield == ShieldBlueNoSharedExpBlink or
shield == ShieldBlueNoSharedExp)
end
function Player:hasVip(creatureName)
for id, vip in pairs(g_game.getVips()) do
if (vip[1] == creatureName) then return true end
end
return false
end
function Player:isMounted()
local outfit = self:getOutfit()
return outfit.mount ~= nil and outfit.mount > 0
end
function Player:toggleMount()
if g_game.getFeature(GamePlayerMounts) then
g_game.mount(not self:isMounted())
end
end
function Player:mount()
if g_game.getFeature(GamePlayerMounts) then
g_game.mount(true)
end
end
function Player:dismount()
if g_game.getFeature(GamePlayerMounts) then
g_game.mount(false)
end
end
function Player:getItem(itemId, subType)
return g_game.findPlayerItem(itemId, subType or -1)
end
function Player:getItems(itemId, subType)
local subType = subType or -1
local items = {}
for i=InventorySlotFirst,InventorySlotLast do
local item = self:getInventoryItem(i)
if item and item:getId() == itemId and (subType == -1 or item:getSubType() == subType) then
table.insert(items, item)
end
end
for i, container in pairs(g_game.getContainers()) do
for j, item in pairs(container:getItems()) do
if item:getId() == itemId and (subType == -1 or item:getSubType() == subType) then
item.container = container
table.insert(items, item)
end
end
end
return items
end
function Player:getItemsCount(itemId)
local items, count = self:getItems(itemId), 0
for i=1,#items do
count = count + items[i]:getCount()
end
return count
end
function Player:hasState(state, states)
if not states then
states = self:getStates()
end
for i = 1, 32 do
local pow = math.pow(2, i-1)
if pow > states then break end
local states = bit32.band(states, pow)
if states == state then
return true
end
end
return false
end
I'm going crazy, because I do not see any error in them.
When I enter in my client, don't show the Inventory
and in the Terminal, show this error
Code:
GPU Intel(R) HD Graphics 4000
OpenGL 4.0.0 - Build 10.18.10.4358
ERROR: unable to open audio device
Found work dir at 'C:/Users/Leonardo/Desktop/The Last Empire/The Last Empire/'
== application started at Oct 31 2017 15:42:18
OTClient 0.6.3 rev 0 (devel) built on Sep 29 2017 for arch x86
Loaded module 'corelib'
Loaded module 'game_things'
Loaded module 'gamelib'
Loaded module 'client'
Loaded module 'client_styles'
Locale 'pl' is missing 1 translations.
["Total Price:"] = "",
Locale 'pt' is missing 19 translations.
["Account Status:"] = "",
["Action:"] = "",
["Amount:"] = "",
["Balance:"] = "",
["Comment:"] = "",
["Don't stretch/shrink Game Window"] = "",
["Find:"] = "",
["Name:"] = "",
["Offer Type:"] = "",
["Piece Price:"] = "",
["Position:"] = "",
["Price:"] = "",
["Reason:"] = "",
["Search:"] = "",
["Statement:"] = "",
["Total Price:"] = "",
["Weight:"] = "",
["Your Capacity:"] = "",
["Your Money:"] = "",
Using configured locale: en
Loaded module 'client_locales'
Loaded module 'client_topmenu'
Loaded module 'client_background'
Loaded module 'client_options'
Loaded module 'client_entergame'
Loaded module 'client_terminal'
Loaded module 'client_modulemanager'
Loaded module 'client_serverlist'
Loaded module 'client_stats'
Loaded module 'game_interface'
Loaded module 'game_hotkeys'
Loaded module 'game_questlog'
Loaded module 'game_textmessage'
Loaded module 'game_console'
Loaded module 'game_outfit'
Loaded module 'game_healthinfo'
Loaded module 'game_skills'
ERROR: failed to load UI from 'inventory.otui': OTML error in '/game_inventory/inventory.otui' at line 53: indentation with tabs are not allowed
ERROR: Unable to load module 'game_inventory': LUA ERROR:
/game_inventory/inventory.lua:34: attempt to index global 'inventoryWindow' (a nil value)
stack traceback:
[C]: in function '__index'
/game_inventory/inventory.lua:34: in function 'init'
/game_inventory/inventory.otmod:8:[@onLoad]:1: in main chunk
[C]: in function 'ensureModuleLoaded'
/init.lua:46: in main chunk
Loaded module 'game_combatcontrols'
Loaded module 'game_containers'
Loaded module 'game_viplist'
Loaded module 'game_battle'
Loaded module 'game_minimap'
Loaded module 'game_npctrade'
Loaded module 'game_textwindow'
Loaded module 'game_playertrade'
Loaded module 'game_bugreport'
Loaded module 'game_playerdeath'
Loaded module 'game_playermount'
Loaded module 'game_ruleviolation'
Loaded module 'game_market'
Loaded module 'game_spelllist'
Loaded module 'game_cooldown'
Loaded module 'game_modaldialog'
Loaded module 'game_unjustifiedpoints'
Loaded module 'myuniqueserver'
Startup done :]
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:111: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
[C]: in function '__index'
/game_inventory/inventory.lua:111: in function 'onInventoryChange'
/game_inventory/inventory.lua:76: in function </game_inventory/inventory.lua:72>
ERROR: Unable to load texture '/images/game/skulls/skull_red': unable to open file '/images/game/skulls/skull_red.png': O sistema não pode encontrar o caminho especificado.
ERROR: invalid effect id 0
at:
[C++]: ?parseMagicEffect@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:111: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
[C]: in function '__index'
/game_inventory/inventory.lua:111: in function </game_inventory/inventory.lua:101>
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:111: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
[C]: in function '__index'
/game_inventory/inventory.lua:111: in function </game_inventory/inventory.lua:101>
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:111: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
[C]: in function '__index'
/game_inventory/inventory.lua:111: in function </game_inventory/inventory.lua:101>
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:111: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
[C]: in function '__index'
/game_inventory/inventory.lua:111: in function </game_inventory/inventory.lua:101>
ERROR: protected lua call failed: LUA ERROR:
/game_inventory/inventory.lua:111: attempt to index global 'inventoryPanel' (a nil value)
stack traceback:
[C]: in function '__index'
/game_inventory/inventory.lua:111: in function </game_inventory/inventory.lua:101>
Thanks!!
CAN DELETE THIS THREAD. I FINNALY GET FIX IT!!!
It was some lines (spaces) that I have to delete to make it work
Last edited: