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

[solved] Background of a Item

knightxd

Member
Joined
Feb 21, 2009
Messages
211
Reaction score
16
Location
Rio de Janeiro
how can i use multiple backgrounds for items?

on \data\images\ui theres item.png, that is used as background for all items, does anyone know how can i edit it? to make multiple backgrounds depending on slot?

thanks!

-- SOLVED -- SOLUTION:

in code.lua

Code:
function onInventoryChange(player, slot, item, oldItem)
  if slot >= InventorySlotPurse then return end
  local itemWidget = inventoryPanel:getChildById('slot' .. slot)
  if itemWidget then
     if item then
       itemWidget:setImageSource('/images/ui/itemB') -- this sets the source if item is on slot
        itemWidget:setItem(item)
     else
        itemWidget:setStyle(InventorySlotStyles[slot])
        itemWidget:setItem(nil)
     end
  end
end
 
Last edited:
yourItemWidget:setImageSource('/images/ui/itemNew')
 
don't got it, do i need to add it on otui file?

yourItemWidget -> has to be references on lua version of this otui?

thanks a lot
 
If you want to change it by script: (assuming your window is referenced by myWindow)
Code:
local itemWidget = myWindow:recursiveGetChildById('myItem')
itemWidget:setImageSource('/images/ui/newItem')

If you want to do it in .otui:
Code:
  Item
    id: yourid
    image-source: /images/ui/newItem
 
didn't worked.. sorry, i guess i missed in my explanation..

i would like to add another type of item background for when the slot are filled with an item..

EX: armor slot..
when it has no armor, displays an armor pic..
When it has, displays ui/item.png.. i would like to change it.. just in case of slot filled..
 
modules/game_inventory/inventory.otui:
Edit these: /images/game/slots/body
 
you are not getting it...

/images/game/slots/body -> is the image of item slot without any item...
/images/ui/Item -> is the background of the slot with an item... (if i set item.png without pixels, it doesnt display slots..)

i would like to change the background of a slot only with an item equiped..
 
Then just copy the styles with background image and replace them with the new image and name them BodySlotFilled, etc.

In lua, instead of:
itemWidget:setStyle('Item')
use:
itemWidget:setStyle(InventorySlotStyles[slot] .. 'Filled')
 
Back
Top