Jump to content

Recommended Posts

Hello everybody. I am making a small mod that improves the functionality of items that are not used often enough. I wanted to make a table of ruins on which it is possible to put trinkets and it would raise the mind a little.
But I don't quite understand why no textures are displayed. I tried to add the option to the regular table but only gems are displayed.

image.png.1f0dcea0fe847b1ff3792f7356fee2e1.png

I thought there was a problem with the names of the animations, because the animations of food and games have the prefix idle. But it didn't help me, I looked at what the lua file of gems and trinkets is annoying, but I still couldn't figure it out.

I think the problem is with the OverrideSymbol, but I don't know how to work with it. Because if I try to give food to a table made of ruins, it is not displayed at all

image.png.901a120666dd3c7ff24689d213e77913.png

I'm passing item.AnimState:GetBuild() so there shouldn't be a problem with that

local function SetFoodSymbol(inst, foodname, override_build)
	if foodname == nil then
		inst.AnimState:ClearOverrideSymbol("swap_cooked")
	else
		inst.AnimState:OverrideSymbol("swap_cooked", override_build, foodname)
	end
end
local function OnGetShelfItem(inst, item)
	if item ~= nil then
		inst.components.trader:Disable()

		SetFoodSymbol(inst, item.prefab, item.AnimState:GetBuild())

		inst.components.shelf.cantakeitem = true

		inst.AnimState:PlayAnimation("hit")
		inst.AnimState:PushAnimation("idle")

		inst.SoundEmitter:PlaySound(sounds.food_fx)
	end
end
Edited by GodIess
SOLVED

Are you new to Animation? I suggest you learn the relevance of a Spriter project and AnimState API.

There is no such layer in ruins table so you need to use Follower.FollowSymbol

The build is not always prefab name.

13 hours ago, Rickzzs said:

Are you new to Animation? I suggest you learn the relevance of a Spriter project and AnimState API.

There is no such layer in ruins table so you need to use Follower.FollowSymbol

The build is not always prefab name.

So I saw that the anim file for the New Year's table has a "swap_cooked" layer, but when unpacking, I don't know where to find it to add the table from the ruins. Regarding the FollowSymbol, I looked at how it is used and mostly it is fx that are attached to some point. But I have an item that I put on the shelf.

inst.components.shelf:PutItemOnShelf(item)

Or I don't quite understand how to use it correctly. Because now I am binding to the table and nothing is displayed, but when I take out the object and drop it, everything is ok..

image.png.851cd3fee0ce406d96a9eea9eeef7de2.pngimage.png.0b8954aaf964078e74de615d5226c0e0.pngimage.png.1bbb101625a295708259337858b48cee.png

it turns out that I bind the object to the table when I put it on the shelf, but being on the shelf it is not displayed, only when I take it and drop it somewhere else

local function SetFoodSymbol(inst, foodname, override_build)
	if foodname == nil then
		inst.AnimState:ClearOverrideSymbol("table01")
	else
	foodname.entity:SetParent(inst.entity)
    foodname.entity:AddFollower():FollowSymbol(inst.GUID, "table01", 0, -150, 0)
		--inst.AnimState:OverrideSymbol("table01", override_build, foodname.prefab)
	end
end

 

If you use Follower you are not supposed to use shelf. You need to write a custom function that does not make the AnimState hide itself when entering limbo. Otherwise you can spawn a new custom prefab to pretend there is an image out there.

If you want to modify animation, you can add a new layer with whatever name you like, and put a transparent image above the table. Then you can do things like winter's feast table.

8 hours ago, Rickzzs said:

If you use Follower you are not supposed to use shelf. You need to write a custom function that does not make the AnimState hide itself when entering limbo. Otherwise you can spawn a new custom prefab to pretend there is an image out there.

If you want to modify animation, you can add a new layer with whatever name you like, and put a transparent image above the table. Then you can do things like winter's feast table.

Thanks, I figured out how to do it and now it works, but now the problem is with the position of the trinkets.

image.png

I think I will throw this idea into a deep hole

Edited by GodIess
  • Like 1
3 hours ago, Rickzzs said:

Oh i forgot that all animations are not aligned. So you can try add a layer. Forget about Follower.

well i looked and only 9 have an offset position.

image.thumb.png.064c2d94fbedda04d4b80081e830d134.pngimage.png.6a964f636459287eab1f569838d8b1a2.pngimage.png.80116bb204591483ecfd85495443b682.png

any ideas how to move programmatically? so that I don't have to change the animation files

I can make a constant position for all others and create an array with coordinates for 9?

Edited by GodIess
7 hours ago, GodIess said:

well i looked and only 9 have an offset position.

image.thumb.png.064c2d94fbedda04d4b80081e830d134.pngimage.png.6a964f636459287eab1f569838d8b1a2.pngimage.png.80116bb204591483ecfd85495443b682.png

any ideas how to move programmatically? so that I don't have to change the animation files

I can make a constant position for all others and create an array with coordinates for 9?

oh, I think I can come up with another solution according to your data. Apparently the trinkets are not aligned, that's why overridesymbol and followsymbol both failed. However, FollowSymbol has e params to adjust position. I'd rather test in game than in Spriter. If you want to test in Spriter, make sure the pivot of trinket matches that of the symbol you will follow. And then record the x,y(the game coordinate maybe different in Spriter) offset needed for adjustment.

3 hours ago, Rickzzs said:

oh, I think I can come up with another solution according to your data. Apparently the trinkets are not aligned, that's why overridesymbol and followsymbol both failed. However, FollowSymbol has e params to adjust position. I'd rather test in game than in Spriter. If you want to test in Spriter, make sure the pivot of trinket matches that of the symbol you will follow. And then record the x,y(the game coordinate maybe different in Spriter) offset needed for adjustment.

Thank you very much for the advice, thanks to you I was able to make a great display with 100 crutch. I spawn an item based on what is in the closet, I disable its saving and the ability to take it into the inventory

local function SetTrinketSymbol(inst, item)
	if item == nil then
		if inst._shelfsymb ~= nil and inst._shelfsymb:IsValid() then
			inst._shelfsymb:Remove()
			inst._shelfsymb = nil
		end
	else
		if inst._shelfsymb == nil then
			inst._shelfsymb = SpawnPrefab(item)
		end
		inst._shelfsymb.persists = false
		inst._shelfsymb:RemoveTag("molebait")
		inst._shelfsymb:RemoveTag("cattoy")
		inst._shelfsymb:RemoveComponent("inventoryitem")
		inst._shelfsymb.entity:AddFollower():FollowSymbol(inst.GUID, "table01", 0, -160, 0)
	end
end

Also, thanks to FollowSymbol, I kept the opportunity to inspect the trinket

image.png.be57e4419f91b5c15f8259ca1b41a9af.pngimage.thumb.png.037aeb17ac8c977fb8bdf57abb61fbad.pngimage.png.d1614c9832371cb42ee51ae32469507b.png

Edited by GodIess
10 minutes ago, little_xuuu said:

Hello author, have you released your mod to the Creative Workshop of steam? Can I subscribe and learn about it?

I do a QoL pack for items that are not used often enough. I have a few more ideas. I will let you know if he is in the workshop

11 hours ago, GodIess said:

I do a QoL pack for items that are not used often enough. I have a few more ideas. I will let you know if he is in the workshop

Can you provide me with some links to learn apis like AnimState, AddFollower, FollowSymbol? I'm a newbie and don't know where to start. I'm trying to provide more options for winter tables.

Cooking pot food is easy to do because klei's code includes it. But some things, like food for the Year of the Pig, or pearls, I have no idea how to do that. For the cooking pot food part, klei used OverrideSymbol("swap_cooked", build, foodname). However, the food in the year of the Pig or the two kinds of pearls have the same build and Symbol, different foods correspond to different anim, such as pearls (idle, cracked), food in the year of the pig (food1, food2, food3).

I try to use AddFollower():FollowSymbol() according to your post, but the corresponding items are only displayed for a moment on the winter table and then they are not visible.

If it is convenient for you, can you provide me with some posts of help or study?

9 hours ago, little_xuuu said:

Can you provide me with some links to learn apis like AnimState, AddFollower, FollowSymbol? I'm a newbie and don't know where to start. I'm trying to provide more options for winter tables.

Cooking pot food is easy to do because klei's code includes it. But some things, like food for the Year of the Pig, or pearls, I have no idea how to do that. For the cooking pot food part, klei used OverrideSymbol("swap_cooked", build, foodname). However, the food in the year of the Pig or the two kinds of pearls have the same build and Symbol, different foods correspond to different anim, such as pearls (idle, cracked), food in the year of the pig (food1, food2, food3).

I try to use AddFollower():FollowSymbol() according to your post, but the corresponding items are only displayed for a moment on the winter table and then they are not visible.

If it is convenient for you, can you provide me with some posts of help or study?

FollowSymbol should be used when you want to glue 1 prefab to another, all you need for this is the name of the layer to which you want to glue the prefab and the position relative to this layer.
OverrideSymbol is used to "change" the texture, for example, in a vase, an empty space is replaced by a flower, but it's still 1 whole texture, while FollowSymbol simply combines 2 objects.

for 1 case you need the name of the layer to which you want to attach the prefab, for 2 case you need the name of the layer you want to replace

 

to see what layers an object has, the easiest option is to open the anim file with a text editor and look at the available layers at the very bottom

image.thumb.png.a5242c2cb2125eaeb960cacfc9a162f5.png

if you want to do something similar to mine. then you probably need to use FollowSymbol like this

I look at what item I have in the container/wardrobe and create exactly that one, and then disable saving for it so that there is no duplicate when loading the world and put it in the appropriate position on the table. Additionally, I removed classes and tags so moles couldn't steal them and all that

if inst._shelfsymb[slot] == nil then
inst._shelfsymb[slot] = SpawnPrefab(data.item.prefab)
end
inst._shelfsymb[slot].persists = false
inst._shelfsymb[slot].entity:AddFollower():FollowSymbol(inst.GUID, "table01", -100, -150, 0)

 

Thank you very much for your answer.

I searched through the game's source code and tried it out. The main problem I found was that I didn't use SetParent().

When I add the SetParent function, it should display normally. I wonder if you have encountered this problem when using it?


if inst._shelfsymb == nil then
	inst._shelfsymb = _G.SpawnPrefab(item.prefab)
end
inst._shelfsymb.persists = false
-- inst._shelfsymb:RemoveTag("molebait")
-- inst._shelfsymb:RemoveTag("cattoy")
-- inst._shelfsymb:RemoveComponent("inventoryitem")
-- inst._shelfsymb:RemoveComponent("perishable")
inst._shelfsymb.entity:SetParent(inst.entity) -- this important
inst._shelfsymb.entity:AddFollower():FollowSymbol(inst.GUID, "swap_cooked", 0, 0, 0)

When I run code without SetParent on the client side, Tiles are displayed at the appropriate location, but only tiles are displayed, and they disappear after re-entering the game.
On the server side, I need to add SetParent for normal display.
I don't know the mechanics involved, because I really don't know anything about animation. Could you explain it to me if you have time? Or related links (I'd prefer to have some links so I can try to retrieve more on my own). If you don't have time, no problem, at least my problem is solved.

Thank you very much.

10 hours ago, little_xuuu said:

Thank you very much for your answer.

I searched through the game's source code and tried it out. The main problem I found was that I didn't use SetParent().

When I add the SetParent function, it should display normally. I wonder if you have encountered this problem when using it?


if inst._shelfsymb == nil then
	inst._shelfsymb = _G.SpawnPrefab(item.prefab)
end
inst._shelfsymb.persists = false
-- inst._shelfsymb:RemoveTag("molebait")
-- inst._shelfsymb:RemoveTag("cattoy")
-- inst._shelfsymb:RemoveComponent("inventoryitem")
-- inst._shelfsymb:RemoveComponent("perishable")
inst._shelfsymb.entity:SetParent(inst.entity) -- this important
inst._shelfsymb.entity:AddFollower():FollowSymbol(inst.GUID, "swap_cooked", 0, 0, 0)

When I run code without SetParent on the client side, Tiles are displayed at the appropriate location, but only tiles are displayed, and they disappear after re-entering the game.
On the server side, I need to add SetParent for normal display.
I don't know the mechanics involved, because I really don't know anything about animation. Could you explain it to me if you have time? Or related links (I'd prefer to have some links so I can try to retrieve more on my own). If you don't have time, no problem, at least my problem is solved.

Thank you very much.

it seems to work for me without it, but I left this command just in case

image.png.853cab9231ccb3b308da121fabb24172.png

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