Booker
New Member
- Joined
- Apr 2, 2015
- Messages
- 46
- Reaction score
- 4
Hello, i'm making my first scripts in lua by my own and got to an issue: i'm trying to create a window where there are 3 slots and only 1 type of item can be assigned to it, it actually looks like this right now:
The problem is, when i try to place any item on them, i get the error:
"You cannot dress this object there."
My question: I don't need the code, just a help to know where i need to edit and if i need to make big changes for this to get going.
Btw, my code:
I part of the code i got from game_interface module...
Tfs 1.2
Thank you!
The problem is, when i try to place any item on them, i get the error:
"You cannot dress this object there."
My question: I don't need the code, just a help to know where i need to edit and if i need to make big changes for this to get going.
Btw, my code:
.otui
lua:
Code:
PartnerSlot < Item
image-source: /images/game/slots/finger
$on:
image-source: /images/game/slots/body-blessed
PartnerSlot_1 < PartnerSlot
id: partnerSlot1
&position: {x=65535, y=6, z=0}
$on:
image-source: /images/game/slots/body-blessed
PartnerSlot_2 < PartnerSlot
id: partnerSlot2
&position: {x=65535, y=4, z=0}
$on:
image-source: /images/game/slots/body-blessed
PartnerSlot_3 < PartnerSlot
id: partnerSlot3
&position: {x=65535, y=5, z=0}
$on:
image-source: /images/game/slots/body-blessed
MiniWindow
id: partnerbag
!text: tr('Partners')
icon: /images/topbuttons/inventory
height: 100
MiniWindowContents
PartnerSlot_1
anchors.right: partnerSlot2.left
anchors.top: parent.top
margin-top: 25
margin-right: 15
PartnerSlot_2
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
margin-top: 10
PartnerSlot_3
margin-top: 25
anchors.left: partnerSlot2.right
anchors.top: parent.top
margin-left: 15
Lua:
partnerWindow = nil
function init()
connect(LocalPlayer,
{
onInventoryChange = onInventoryChange
}
)
partnerWindow = g_ui.loadUI('partnerstats', modules.game_interface.getRightPanel())
partnerWindow:disableResize()
partnerStatsButton = modules.client_topmenu.addRightGameToggleButton(
'partnerStatsButton',
tr('Partners'),
'/images/topbuttons/login',
toggle
)
partnerStatsButton:setOn(true)
refresh()
partnerWindow:setup()
end
function onInventoryChange(player, slot, item, oldItem)
local itemWidget = partnerWindow:getChildById('partnerSlot'..slot)
if item then
itemWidget:setItem(item)
else
itemWidget:setItem(nil)
end
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 terminate()
disconnect(LocalPlayer,
{
onInventoryChange = onInventoryChange
}
)
partnerWindow:destroy()
partnerStatsButton:destroy()
end
function toggle()
if partnerWindow:isVisible() then
partnerWindow:hide()
partnerStatsButton:setOn(false)
else
partnerWindow:show()
partnerStatsButton:setOn(true)
partnerWindow:focus()
end
end
Tfs 1.2
Thank you!
Last edited: