Jump to content

Mini Signs are incompatible with MOD items


Mobbstar
  • Known Issue

The Mini Signs do not use the inventoryitem.atlasname property when getting drawn on. Therefore, all items with custom atlas (i.e. all mod items) do not display by default.

Partial solution:

Spoiler

 

This is the original function:


local function OnDrawnFn(inst, image, src)
    if image ~= nil then
        inst.AnimState:OverrideSymbol("SWAP_SIGN", "images/inventoryimages.xml", image..".tex")
        if inst:HasTag("sign") then
            inst.components.drawable:SetCanDraw(false)
            inst._imagename:set(src ~= nil and (src.drawnameoverride or src:GetBasicDisplayName()) or "")
            if src ~= nil then
                inst.SoundEmitter:PlaySound("dontstarve/common/together/draw")
            end
        end
    else
        inst.AnimState:ClearOverrideSymbol("SWAP_SIGN")
        if inst:HasTag("sign") then
            if not (inst.components.burnable ~= nil and inst.components.burnable:IsBurning()) then
                inst.components.drawable:SetCanDraw(true)
            end
            inst._imagename:set("")
        end
    end
end

Without changing any function parameters, this tweak fixes the bug:


local function OnDrawnFn(inst, image, src)
    if image ~= nil then
    	local atlas = (src and src.components.inventoryitem and src.components.inventoryitem.atlasname) or "images/inventoryimages.xml"
        inst.AnimState:OverrideSymbol("SWAP_SIGN", atlas, image..".tex")
        if inst:HasTag("sign") then
        	--[...]

 

 

 

You might need to add a second netvar for the atlas. Nevertheless, it is a rather easy issue, hopefully you fix it soon. Thanks for reading and stay awesome Klei!  ^_^


Steps to Reproduce
1) Plant a minisign 2) Place a mod item (with custom image) nearby 3) Use a Feather Pencil on the sign
  • Like 1



User Feedback


It's actually a little more complex because the atlas is being used an as anim build instead of a regular atlas, which is denoted by this asset that the minisign prefab references ( Asset("ATLAS_BUILD", "images/inventoryimages.xml", 256), )
 

There's a slight difference from what you posted, it also needs to resolve the filepath. I'll be adding this functionality, but it'll still rely on the modder to create an ATLAS_BUILD for their inventory image at this time.

local atlas = (src and src.components.inventoryitem and src.components.inventoryitem.atlasname and resolvefilepath(src.components.inventoryitem.atlasname) ) or "images/inventoryimages.xml"

So for mod icons to appear on minisigns they'll need to a link to their inventory atlas, like this for the Opal Amulet mod.

Asset("ATLAS_BUILD", "images/inventoryimages/opalamulet.xml", 256),

Ideally this would be done automatically, but I don't see a clean way right now to identify at asset loading time which atlases need to be converted into builds to be used by the minisign.

  • Like 1

Share this comment


Link to comment
Share on other sites

Out of curiosity, what exactly does the parameter (256) mean? The purchasable skins use a different parameter for their ATLAS_BUILD (for opening the chest I suppose).

Share this comment


Link to comment
Share on other sites

On 10/6/2018 at 1:57 AM, Mobbstar said:

Out of curiosity, what exactly does the parameter (256) mean? The purchasable skins use a different parameter for their ATLAS_BUILD (for opening the chest I suppose).

That parameter is scale of the build. It's used for creating the vertex data for the symbols in the build. The build is what determines how large something in an animation is, so need to specify how large these override symbols are going to be.

  • Like 1
  • Thanks 1

Share this comment


Link to comment
Share on other sites

On 2018/10/3 at 6:01 AM, PeterA said:

It's actually a little more complex because the atlas is being used an as anim build instead of a regular atlas, which is denoted by this asset that the minisign prefab references ( Asset("ATLAS_BUILD", "images/inventoryimages.xml", 256), )
 

There's a slight difference from what you posted, it also needs to resolve the filepath. I'll be adding this functionality, but it'll still rely on the modder to create an ATLAS_BUILD for their inventory image at this time.


local atlas = (src and src.components.inventoryitem and src.components.inventoryitem.atlasname and resolvefilepath(src.components.inventoryitem.atlasname) ) or "images/inventoryimages.xml"

So for mod icons to appear on minisigns they'll need to a link to their inventory atlas, like this for the Opal Amulet mod.

Asset("ATLAS_BUILD", "images/inventoryimages/opalamulet.xml", 256),

Ideally this would be done automatically, but I don't see a clean way right now to identify at asset loading time which atlases need to be converted into builds to be used by the minisign.

I tried adding the code you said to the file like the following.

local assets =
{
    Asset("ANIM", "anim/torso_opalamulet.zip"),
   Asset("ANIM", "anim/opalamulet_ground.zip"),
   Asset("ANIM", "anim/opalamulet_fx.zip"),
   Asset("ANIM", "anim/shadow_upgrade.zip"),
   
   Asset("IMAGE", "images/inventoryimages/opalamulet.tex"),
   Asset("ATLAS", "images/inventoryimages/opalamulet.xml"),
   Asset("ATLAS_BUILD", "images/inventoryimages/opalamulet.xml", 256),
}

But when I draw the amulet to the mini sign, the log shows "Could not find anim build FROMNUM", which means it failed.

Share this comment


Link to comment
Share on other sites

@gznc as PeterA stated, the "ATLAS_BUILD" is not a regular image atlas and has to be compiled differently. We currently do not have tools to do this, as far as I know. Klei's internal tool for compiling atlas_build is probably unsuitable for public use in its current state, too.

Share this comment


Link to comment
Share on other sites

14 hours ago, bizziboi said:

No, it should not need a special tool as far as I know. the game needs a minor modification. 

I think so. I exported the "inventoryimages.tex" to "inventoryimages.png" then compress it into the new tex and replace the former one. It still works.

22 minutes ago, gznc said:

I think so. I exported the "inventoryimages.tex" to "inventoryimages.png" then compress it into the new tex and replace the former one. It still works.

Add my files to "frontend.lua" and "hud.lua" like "inventoryimages", it solved.

Share this comment


Link to comment
Share on other sites

 

7 hours ago, gznc said:

Add my files to "frontend.lua" and "hud.lua" like "inventoryimages", it solved.

If I a not mismtaken, the minisign needs to serialize out/in the texture name or it won't work on reload.

  • Thanks 1

Share this comment


Link to comment
Share on other sites

7 hours ago, gznc said:

Add my files to "frontend.lua" and "hud.lua" like "inventoryimages", it solved.

Could you elaborate, Im even manually inserting into the games files, and its still not working.

Share this comment


Link to comment
Share on other sites

added the following lines to both the prefab itself and to the modmain
    Asset("ATLAS", "images/inventoryimages/fruit_truffle.xml"),
    Asset("ATLAS_BUILD", "images/inventoryimages/fruit_truffle.xml", 256),
still no luck (see image below)

Is this related to why modded items don't show up when put on shelves in Hamlet?

image.png.63d54f17ebd514516d417844483b4c1e.png

 

Share this comment


Link to comment
Share on other sites

1 hour ago, MidrealmDM said:

Is this related to why modded items don't show up when put on shelves in Hamlet?

I don't know about Hamlet, but look at this:

 

Share this comment


Link to comment
Share on other sites

6 hours ago, Mobbstar said:

I don't know about Hamlet, but look at this:

 

Thank you, do I place this code (below) in the modmain?

Spoiler

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

 

 

 

 

 

 

Share this comment


Link to comment
Share on other sites

5 hours ago, MidrealmDM said:

Thank you, do I place this code (below) in the modmain?

Yes, except you have to replace "images/ia_inventoryimages.xml" with "images/inventoryimages/fruit_truffle.xml", of course. If you have several items, it's probably easier to pack them into one atlas.

  • Thanks 1

Share this comment


Link to comment
Share on other sites

1 minute ago, Mobbstar said:

Yes, except you have to replace "images/ia_inventoryimages.xml" with "images/inventoryimages/fruit_truffle.xml", of course. If you have several items, it's probably easier to pack them into one atlas.

LOL - I do have several ... if you call over 100 several.

Thanks

Share this comment


Link to comment
Share on other sites

On 5/24/2019 at 2:25 PM, Mobbstar said:

Yes, except you have to replace "images/ia_inventoryimages.xml" with "images/inventoryimages/fruit_truffle.xml", of course. If you have several items, it's probably easier to pack them into one atlas.

Ok - so I rebuilt the xml and tex, but I get this error
"variable 'UpvalueHacker' is not declared"

Share this comment


Link to comment
Share on other sites

25 minutes ago, MidrealmDM said:

Ok - so I rebuilt the xml and tex, but I get this error
"variable 'UpvalueHacker' is not declared"

Right, we use the UpvalueHacker as included in the GemCore API. You can rewrite the code to not require GemCore, by replacing inventoryItemAtlasLookup with a new cache, but that causes more calls of AtlasContains for vanilla items...

Really, Klei should provide some proper way for mods to add their atlases to this function.

Share this comment


Link to comment
Share on other sites

On 10/2/2018 at 5:01 PM, PeterA said:

So for mod icons to appear on minisigns they'll need to a link to their inventory atlas, like this for the Opal Amulet mod.

Asset("ATLAS_BUILD", "images/inventoryimages/opalamulet.xml", 256),

 

does the modder simply need to include this line in their modmain

Asset("ATLAS_BUILD", "images/inventoryimages/<item.xml>", 256),

or can it be listed within the prefab?
Also what is the significance of '256' and does it need to remain a constant.?

Share this comment


Link to comment
Share on other sites

39 minutes ago, MidrealmDM said:

does the modder simply need to include this line in their modmain

Asset("ATLAS_BUILD", "images/inventoryimages/<item.xml>", 256),

or can it be listed within the prefab?
Also what is the significance of '256' and does it need to remain a constant.?

I don't think it will work from the prefab, because then minisigns wouldn't have the asset until that prefab spawns. (Which is why birdcages and dryingracks have to load bird/meat assets explicitly, in case that bird/meat didn't spawn by the time the cage/rack loads.)

As for the number, Zarklord told me it's the "scale". I haven't tried changing it, on the basis of "this works and won't break anytime soon".

Share this comment


Link to comment
Share on other sites

Ok,

On 2/4/2019 at 4:15 AM, gznc said:

I tried adding the code you said to the file like the following.

But when I draw the amulet to the mini sign, the log shows "Could not find anim build FROMNUM", which means it failed.

likewise -
Assets = {
    Asset("IMAGE", "images/inventoryimages/zucchilli.tex"),
    Asset("ATLAS", "images/inventoryimages/zucchilli.xml"),
    Asset("ATLAS_BUILD", "images/inventoryimages/zucchilli.xml", 256),
}

=-=-=-=
log file shows:
[00:02:23]: SimLuaProxy::QueryServer()
[00:02:31]: giving     132272 - zucchilli    
[00:02:37]: giving     132469 - featherpencil    
[00:02:42]: Could not find anim build FROMNUM
[00:02:43]: SimLuaProxy::QueryServer()

ZucchilliCapture.PNG

Share this comment


Link to comment
Share on other sites



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...