NeddoFreddo Posted July 21, 2016 Share Posted July 21, 2016 Heyo, I am having trouble with structure animations. these 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 More sharing options...
Muche Posted July 21, 2016 Share Posted July 21, 2016 Attach you goldchest prefab file. Or compare your code with how treasurechest/icebox prefabs handle animations on those events. Link to comment Share on other sites More sharing options...
NeddoFreddo Posted July 21, 2016 Author Share Posted July 21, 2016 (edited) 1 hour ago, Muche said: Attach you goldchest prefab file. Or compare your code with how treasurechest/icebox prefabs handle animations on those events. @Muchek, here they are. goldchest.lua goldchest.scml goldchest.zip and the scml files just incase Edited July 21, 2016 by NeddoFreddo Link to comment Share on other sites More sharing options...
Muche Posted July 21, 2016 Share Posted July 21, 2016 (edited) 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 July 21, 2016 by Muche Link to comment Share on other sites More sharing options...
NeddoFreddo Posted July 21, 2016 Author Share Posted July 21, 2016 (edited) @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 July 21, 2016 by NeddoFreddo Link to comment Share on other sites More sharing options...
NeddoFreddo Posted July 22, 2016 Author Share Posted July 22, 2016 Hmm... i was also wondering if there was a way to make an idle animation for a structure loop? I have another structure and it's idle animation is supposed to loop, but it only plays once then stops. Link to comment Share on other sites More sharing options...
Muche Posted July 22, 2016 Share Posted July 22, 2016 The second parameter for PlayAnimation/PushAnimation is a boolean for looping; setting it to true should make that animation loop. Link to comment Share on other sites More sharing options...
NeddoFreddo Posted July 22, 2016 Author Share Posted July 22, 2016 (edited) 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 July 22, 2016 by NeddoFreddo Link to comment Share on other sites More sharing options...
Muche Posted July 23, 2016 Share Posted July 23, 2016 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 More sharing options...
NeddoFreddo Posted July 23, 2016 Author Share Posted July 23, 2016 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 Link to comment Share on other sites More sharing options...
Muche Posted July 23, 2016 Share Posted July 23, 2016 Could you attach the whole mod (including exported folder), so I could try it? Link to comment Share on other sites More sharing options...
NeddoFreddo Posted July 23, 2016 Author Share Posted July 23, 2016 1 hour ago, Muche said: Could you attach the whole mod (including exported folder), so I could try it? Voila. (it's called [new] because there was an old version not workig properly) [NEW] Furniture Mod.zip Link to comment Share on other sites More sharing options...
Muche Posted July 23, 2016 Share Posted July 23, 2016 I tried to resize the goldchest in only idle animation and it worked. (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 More sharing options...
NeddoFreddo Posted July 23, 2016 Author Share Posted July 23, 2016 (edited) 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 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 July 23, 2016 by NeddoFreddo Link to comment Share on other sites More sharing options...
NeddoFreddo Posted July 24, 2016 Author Share Posted July 24, 2016 Also, I tried editing a previous animation for a structure, and I get this in the sutocompiler: 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now