Jump to content

Structure animation problems


Recommended Posts

Heyo,

I am having trouble with structure animations.

Capture.PNGthese are my 4 animations for the chest atm

The idle animation is working fine, however I am experiencing problems with the other three.

-place doesn't happen at all ingame when I build the chest

-hit kinda works when i hit it with a hammer, but after the hit animation has played the chest turns invisible

-And open is fine but I'd like to know how to add an opening animation, not just a state for when the chest's open.

Thanks for reading, and helping if you can.

Link to comment
Share on other sites

1) onbuilt() function is not referenced anywhere. Add inst:ListenForEvent("onbuilt", onbuilt) into fn().

2) onhit() function schedules hit animation, followed by closed animation that is not present in the scml. Replace closed with idle in onhit() function.

3) AFAIK, AnimState:PlayAnimation() replaces all currently scheduled animations, AnimState:PushAnimation() adds an animation at the end of the animation queue. So add a new opening animation, e.g. opening, then in onopen() function:

inst.AnimState:PlayAnimation("opening") 
inst.AnimState:PushAnimation("open", true) 

 

Edited by Muche
Link to comment
Share on other sites

@Muche Hey thanks for the help! Everything with the chest is fine now, except for 1 thing. I also added a close animation.

The build animation now plays but the chest turns invisible after the animation has played.

EDIT: o nvm i just changed this:

local function onbuilt(inst)
    inst.AnimState:PlayAnimation("place") --place
    inst.AnimState:PushAnimation("closed", true)
    inst.SoundEmitter:PlaySound("dontstarve/common/dragonfly_chest_craft")
end

to this:

local function onbuilt(inst)
    inst.AnimState:PlayAnimation("place") --place
    inst.AnimState:PushAnimation("idle", true)
    inst.SoundEmitter:PlaySound("dontstarve/common/dragonfly_chest_craft")
end

 

Edited by NeddoFreddo
Link to comment
Share on other sites

10 hours ago, Muche said:

The second parameter for PlayAnimation/PushAnimation is a boolean for looping; setting it to true should make that animation loop.

You mean this?

inst.AnimState:PlayAnimation("place") 
	inst.AnimState:PushAnimation("idle", true)

Because I changed that, and it works, but only if you actually build the structure. If you spawn it in, the animation only plays once, which might not seem like much of a big deal, but when you exit the game and join in again the animation, yes, only plays once.

One last question, one of the structures is a little bit small ingame, but if I resize it in the spriter file it messes up the animation. So is there a way to set it's scale in the files somehow? I've seen something like this in other mods before.

Edited by NeddoFreddo
Link to comment
Share on other sites

1) When a structure is built:
components/builder|DoBuild() spawns the entity (i.e. its fn function is run), then onbuilt event is pushed (i.e. your onbuilt function is called)

2) When a structure is debug spawned:
util|DebugSpawn() spawns the entity (i.e. its fn function is run).

3) When a structure is loaded from the save:
mainfunctions|SpawnSaveRecord() spawns the entity (i.e. its fn function is run).

Thus, you'll have to set the loop parameter for the AnimState:PlayAnimation() call in fn function as well.


What do you mean by "messes up the animation"? Do you mean that the size changes suddenly when different animations are played?

Link to comment
Share on other sites

1 hour ago, Muche said:

What do you mean by "messes up the animation"? Do you mean that the size changes suddenly when different animations are played?

Well, kinda. In spriter I selected everything in the animation and resized it,but that made some parts of the animtion jump around when the animation is played, notably the moving parts.

Also yeah thanks now the structure animation always loops :D

Link to comment
Share on other sites

I tried to resize the goldchest in only idle animation and it worked.

big_idle_goldchest.jpg

(other animations use resizing as well and they work too).

Did you resize the image object in all key frames?
I noticed that spriter doesn't update object properties (position, scale, angle) when the timeline frame number changes as I would expect. I had to clear the selection and select the image object again to see its new properies.

Link to comment
Share on other sites

9 hours ago, Muche said:

(other animations use resizing as well and they work too).

Did you resize the image object in all key frames?
I noticed that spriter doesn't update object properties (position, scale, angle) when the timeline frame number changes as I would expect. I had to clear the selection and select the image object again to see its new properies.

Well when I select all keyframes the non-moving parts work normally, but the moving bits seem to stuff up. (I am trying to resize the shrine, btw)

I once saw in someone's code, something like

inst.transform:SetScale(2, 2)

It probably wasn't exactly that, but what it did was change the size of a structure through the code.

Do you know what the correct code is for SetScale?

On another note, I was wondering how you'd add a recipe for an existing structure into the game. (in this case maxwell statue.)

I tried this:

Spoiler

local myrecipe = AddRecipe("statuemaxwell",
{Ingredient("marble", 4)}, 
GLOBAL.RECIPETABS.FARM, 
GLOBAL.TECH.SCIENCE_TWO, 
"chessboard_placer", -- i used this because i couldn't be stuffed making a maxwell placer
nil, -- min_spacing
nil, -- nounlock
nil, -- numtogive
nil, 
)

 

but I get this:

Spoiler

Screenshot (71).png

Which is weird. I've never seen a crash screen like that before XD

(I cant get rid of the ')' because then the whole page gets engulfed within the depths of a recipe function)

And yes, I've added a recipe description.

Edited by NeddoFreddo
Link to comment
Share on other sites

Also, I tried editing a previous animation for a structure, and I get this in the sutocompiler:

Screenshot (72).png

The game doesn't crash it just shows the old aimation.

Sorry for pestering you with so many problems and questions, I'm just relatively new to this modding thing. :)

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
 Share

×
  • Create New...