• 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!

How to create a item image from item id in OTClient?

TheGahl

Learning in Progress
Joined
Jul 28, 2018
Messages
200
Solutions
3
Reaction score
124
I'm trying to understand how OTClient works and now I'm stuck at another problem I've spent the whole day trying to figure out.

I'm trying to create a window, similar to message of the day.
Within that window I have a square box there I'd like to display a random item.

But I have no idea how to actually display the item.
I know how to show images from otclient image folder, but I need to figure out how to display images from the .dat and .spr file.
As long I've experimented I've tried functions like "box:setItemId(666)", but I don't know how to properly use them.

Could anyone please tell me how to display any item from the game by a given id (game id, or client id, doesn't matter which)

Thanks in advance!
 
I'm trying to understand how OTClient works and now I'm stuck at another problem I've spent the whole day trying to figure out.

I'm trying to create a window, similar to message of the day.
Within that window I have a square box there I'd like to display a random item.

But I have no idea how to actually display the item.
I know how to show images from otclient image folder, but I need to figure out how to display images from the .dat and .spr file.
As long I've experimented I've tried functions like "box:setItemId(666)", but I don't know how to properly use them.

Could anyone please tell me how to display any item from the game by a given id (game id, or client id, doesn't matter which)

Thanks in advance!
If it's only one item box that will be displayed in window each time then you can make an Item widget within the otui like this (adjust anchors and margin to fit what you need):
Code:
  Item
    id: itemWidget
    size: 32 32
    anchors.left: parent.left
    anchors.top: parent.top
    margin: 10
    virtual: true

Then in lua you can assign the widget to a globally declared variable like this:
Lua:
mainWindow = nil
itemWidget = nil

function init()
    -- make sure mainWindow is assigned to the global variable
    itemWidget = mainWindow:getChildById('itemWidget')

Then whenever you open window and want to set the item id you can simply do this:
Lua:
itemWidget:setItemId(itemId) -- client id only

Look into the hotkey_manager module to see how it shows the itemPreview, that will have everything you need to figure it out.
 
If it's only one item box that will be displayed in window each time then you can make an Item widget within the otui like this (adjust anchors and margin to fit what you need):
Code:
  Item
    id: itemWidget
    size: 32 32
    anchors.left: parent.left
    anchors.top: parent.top
    margin: 10
    virtual: true

Then in lua you can assign the widget to a globally declared variable like this:
Lua:
mainWindow = nil
itemWidget = nil

function init()
    -- make sure mainWindow is assigned to the global variable
    itemWidget = mainWindow:getChildById('itemWidget')

Then whenever you open window and want to set the item id you can simply do this:
Lua:
itemWidget:setItemId(itemId) -- client id only

Look into the hotkey_manager module to see how it shows the itemPreview, that will have everything you need to figure it out.

Thank you a lot for the reply :)
It turns out I was doing it right, just that I was testing the code with a init function which made the code execute before the .dat or .spr was loaded xD
But thanks anyway, your reply was useful :)
 
Back
Top