Jump to content

need help about inventory image


Recommended Posts

Please help me!It's my first time making a mod.

I don't want to set the inventory image separately for each prefab. And I want minisign worked.

So I imitate Island Adventure mod. I almost made it.

I packed all my tex files into one file. And I imported it as forum do 

Assets = {
    Asset("ATLAS", "images/ws_inventoryimages.xml"),
    Asset("IMAGE", "images/ws_inventoryimages.tex"),
    Asset("ATLAS_BUILD", "images/ws_inventoryimages.xml", 256)
}

Here's part of my code:

local UpvalueHacker = require('utils/upvaluehacker')
GLOBAL.require("simutil")
local GetInventoryItemAtlas_old = GLOBAL.GetInventoryItemAtlas
local inventoryItemAtlasLookup = UpvalueHacker.GetUpvalue(
                                     GLOBAL.GetInventoryItemAtlas,
                                     "inventoryItemAtlasLookup")
local ws_inventoryimages = GLOBAL.resolvefilepath(
                               "images/ws_inventoryimages.xml")
 
GLOBAL.GetInventoryItemAtlas = function(imagename)
    if inventoryItemAtlasLookup[imagename] then
        return inventoryItemAtlasLookup[imagename]
    end
    if GLOBAL.TheSim:AtlasContains(ws_inventoryimages, imagename) then
        inventoryItemAtlasLookup[imagename] = ws_inventoryimages
        return ws_inventoryimages
    end
    return GetInventoryItemAtlas_old(imagename)
end

But inventory image don't appear when I enter the game.

My item's inventory image just become a black square.

image.png.7869401006d6df4f7c0b2f92eb55bab0.png

After I draw my item on minisign. It worked! Not being a black square again.

I don't know why.

Apparently it related to this line:

inst.AnimState:OverrideSymbol("SWAP_SIGN", atlas or
                                          GetInventoryItemAtlas(image .. ".tex"),
                                      image .. ".tex")

But I can't find definition of AnimState:OverrideSymbol

I don't know why it can make inventory image work again.

What can I do to fix this?

This tormented me a lot. I would appreciate it if someone could help me! Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...