Jump to content

Mods need to edit GetInventoryItemAtlas (for Minisigns and Inspect Player)


Mobbstar
  • Pending

Minisign code:

local function OnDrawnFn(inst, image, src)
    if image ~= nil then
        local atlas = nil
        if src ~= nil and src.replica.inventoryitem ~= nil then
            atlas = src.replica.inventoryitem:GetAtlas()
        else
            atlas = GetInventoryItemAtlas(image..".tex")
        end
        
        inst.AnimState:OverrideSymbol("SWAP_SIGN", atlas, image..".tex")

Minisigns use GetInventoryItemAtlas for vanilla items. This returns a string and it works just fine.

If the item has replica.inventoryitem:GetAtlas() (presumably mod items), that returns a netvar hash, not a string. OverrideSymbol cannot use this hash. Minisign cannot display such items.

Inspecting a player displays the current equipment using GetInventoryItemAtlas too.

In "Island Adventures" we now edit GetInventoryItemAtlas instead of setting inventoryitem.atlasname
Here's the IA code for reference:

Spoiler

 


--fix item images in menu and on minisigns
GLOBAL.require("simutil")
local GetInventoryItemAtlas_old = GLOBAL.GetInventoryItemAtlas
local inventoryItemAtlasLookup = GLOBAL.UpvalueHacker.GetUpvalue(GLOBAL.GetInventoryItemAtlas, "inventoryItemAtlasLookup")
local ia_inventoryimages = GLOBAL.resolvefilepath("images/ia_inventoryimages.xml")
GLOBAL.GetInventoryItemAtlas = function(imagename)
	if inventoryItemAtlasLookup[imagename] then
		return inventoryItemAtlasLookup[imagename]
	end
	if GLOBAL.TheSim:AtlasContains(ia_inventoryimages, imagename) then
		inventoryItemAtlasLookup[imagename] = ia_inventoryimages
		return ia_inventoryimages
	end
	return GetInventoryItemAtlas_old(imagename)
end

I suggest you let mods insert their atlases into GetInventoryItemAtlas one way or another. It reduces network traffic and is easier for the UI.


Steps to Reproduce
Minisigns: 1. open any vanilla item code 2. set inst.components.inventoryitem.atlasname = GetInventoryItemAtlas( inst.prefab ..".tex" ) 3. start the game 4. the item shows up correctly in itemtile widgets, but cannot be drawn on minisigns Inspect: 1. equip any mod item and click the Self-Inspect button 2. the pop-up has a blank space where the item should be
  • Like 1



User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...