Jump to content

OverrideSymbol: How to?


Recommended Posts

I'm trying to get this to work for quite a while now, but I can't figure it out.
This is totally not a consequence of the frequent requests on Steam regarding my Pigspikes! mod...
Here's my prefab:

local assets = {Asset("ANIM","anim/myprefab.zip"),--Debug:Asset("ANIM", "anim/statue_ruins_small.zip"),Asset("ANIM", "anim/statue_ruins_small_gem.zip"),}local function OnFinish(inst)SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())inst.SoundEmitter:PlaySound("dontstarve/common/destroy_wood")inst.components.lootdropper:DropLoot()inst.components.container:DropEverything()inst:Remove()endlocal function OnWork(inst)inst.components.container:DropEverything()endlocal function OnOpen(inst)inst.components.container:DropEverything()endlocal function ItemTest(inst, item, slot)if item.components.equippable and item.components.equippable.equipslot == EQUIPSLOTS.HEAD thenreturn trueendreturn falseendlocal function UpdateDisplay(inst, data)inst.AnimState:ClearOverrideSymbol("trophy")local item = data.itemif item and item.components.equippable thenlocal s = item.prefabif string.find(s, ".hat") thens = s:gsub(".hat",".") --totally not going to workends = "hat_" .. sinst.AnimState:OverrideSymbol("trophy",s,s) --this seems to not workinst.AnimState:OverrideSymbol("swap_gem", "statue_ruins_small_gem", "greengem") --debug--name, anim, build; I guess based on other filesendendlocal function commonfn(inst)inst.entity:AddTransform()inst.entity:AddAnimState()inst.entity:AddSoundEmitter()inst:AddComponent("inspectable")inst:AddComponent("lootdropper")inst:AddComponent("workable")inst.components.workable:SetWorkAction(ACTIONS.HAMMER)inst.components.workable:SetWorkLeft(3)inst.components.workable.onfinish = OnFinishinst.components.workable.onwork = OnWorkinst:AddComponent("container")inst.components.container.acceptsstacks = falseinst.components.container.numslots = 1inst.components.container.onopenfn = OnOpeninst.components.container.widgetslotpos = {Vector3(0,0,0)}inst.components.container.side_align_tip = 0inst.components.container.widgetpos = Vector3(0,600,0)return instendlocal function myprefabfn()local inst = CreateEntity()commonfn(inst)MakeObstaclePhysics(inst, .4)inst.AnimState:SetBank("statue_ruins_small") --Debuginst.AnimState:SetBuild("statue_ruins_small")-- inst.AnimState:SetBank("marble_pillar")-- inst.AnimState:SetBuild("myprefab")inst.AnimState:PlayAnimation("full")inst.components.container.itemtestfn = ItemTestinst:ListenForEvent("itemget", UpdateDisplay)return instendreturn Prefab("forest/objects/myprefab", myprefabfn, assets),

Everything works, but the AnimState:OverrideSymbol...

 

As you can see, I've tried to do the ruins statue. That worked, so I think OverrideSymbol is anim-specific. But I still don't understand why it is.

EDIT: I think there is an invisible placeholder. Please, oh please don't say that I have to use... *gulp* Spriter.

 

Any thoughts?

Link to comment
Share on other sites

I don't know what are the symbol names on that particular anim, nor am I sure what you're trying to do tbh. But OverrideSymbol arguments are: original animation symbol name (that you're trying to replace), build name (of a build you will pull the symbol that you want to put in the original one's place from, usually the anim zip name), symbol name of replacement (that is the name of the symbol as defined in the build you supplied as 2nd argument).

 

I'm guessing OverrideSymbol("trophy", etc doesn't work because animation you are using ("full") doesn't have reference to trophy symbol? Obviously, the first argument has to be a symbol that animation is actually referencing or it will do nothing. Also the symbol from the last argument has to actually have the appropriate textures that are used in animation (if anim requests item-4.png and your symbol doesn't have it it won't load anything, unless the build is set with certain flags, which I'm still confused with)

Link to comment
Share on other sites

I don't know what are the symbol names on that particular anim, nor am I sure what you're trying to do tbh. But OverrideSymbol arguments are: original animation symbol name (that you're trying to replace), build name (of a build you will pull the symbol that you want to put in the original one's place from, usually the anim zip name), symbol name of replacement (that is the name of the symbol as defined in the build you supplied as 2nd argument).

 

I'm guessing OverrideSymbol("trophy", etc doesn't work because animation you are using ("full") doesn't have reference to trophy symbol? Obviously, the first argument has to be a symbol that animation is actually referencing or it will do nothing. Also the symbol from the last argument has to actually have the appropriate textures that are used in animation (if anim requests item-4.png and your symbol doesn't have it it won't load anything, unless the build is set with certain flags, which I'm still confused with)

 

Okay, I tried to clean things up and made a custom anim with spriter (attached).

In detail... It has two animations: idle and hit. It consists of a board texture and two pole textures. I've tested it in-game already.

 

How can I declare a space as the symbol (the one which I want to override later)? I couldn't find a hint by decompiling the crock pot anim.

Link to comment
Share on other sites

Subdirectory name of your image file(s) = symbol name that will be assigned to them (counting from where your scml file resides, that is)

 

That means you can/have to make a dummy placeholder image (it can be whatever, 1x1 transparent image), put it into the subdir of your spriter project that corresponds to the symbol name you wish to use, then drag it into the scene where you want it to show. You can use multiple ones, do image swapping animation whatever as if they were normal objects. Finally, when you do overridesymbol in code, with the actual build/image, it's almost the same as if you were to copy paste the directory from override build into your spriter build (almost because the symbol names can differ, so can file names and they would still match on frame to frame basis, and there are certain cases - e.g. simply having BUILD anim name that seem to be making it ignore filenames - that I don't get for the life of me)

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