Sylva Posted October 14, 2018 Share Posted October 14, 2018 So Im starting work on my second character mod, my first one really only required I changed some values that already existed in the base files for her perks, but for this character, I really want to make it so he transforms into a different form when his sanity is low. Im guessing I could probably recycle code from Woodie's beaver transformation, but I have no idea how I'd tell it to change with sanity, as well as how I'd link the sprite. Im asking now because i dont like waiting and want to finish this mod relatively quickly because it's partially for a friend. (Sorry if I reply late to anyone on here, im multitasking, so I might not be able to see it until tomorrow, especially since it's already quite late here) Link to comment Share on other sites More sharing options...
BakaSchwarz Posted October 15, 2018 Share Posted October 15, 2018 This sounds like an easy job for DoPeriodicTask. With it you can do things in a set interval (like checking your characters sanity) I would do something like this: local master_postinit = function(inst) inst:DoPeriodicTask(1, function() if inst.components.sanity:GetPercent() < 0.5 then -- Do stuff else -- Do other stuff end end) end When you wish to change a characters visual appearance, i think you mean to change it's build? I have made a character that changes her appearance based on the season: local winter_skin = false local function HandleSkinChange(inst) if TheWorld.state.iswinter and not winter_skin then winter_skin = true inst.AnimState:SetBuild("avia_winter") elseif not TheWorld.state.iswinter and winter_skin then winter_skin = false inst.AnimState:SetBuild("avia") end end What does this mean? Well, in my anim folder i have two ZIP-Files: avia.zip and avia_winter.zip. Of course avia.lua, my character prefab, loads both assets: local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset( "ANIM", "anim/avia.zip" ), Asset( "ANIM", "anim/avia_winter.zip"), } If you want to, you can always check the mod yourself as a start. I attach it to this post. avia_packed.zip Link to comment Share on other sites More sharing options...
Sylva Posted October 15, 2018 Author Share Posted October 15, 2018 Thanks! It is confusing to me but everything was confusing in the beginning! Ill catch on 1 hour ago, BakaSchwarz said: This sounds like an easy job for DoPeriodicTask. With it you can do things in a set interval (like checking your characters sanity) I would do something like this: local master_postinit = function(inst) inst:DoPeriodicTask(1, function() if inst.components.sanity:GetPercent() < 0.5 then -- Do stuff else -- Do other stuff end end) end When you wish to change a characters visual appearance, i think you mean to change it's build? I have made a character that changes her appearance based on the season: local winter_skin = false local function HandleSkinChange(inst) if TheWorld.state.iswinter and not winter_skin then winter_skin = true inst.AnimState:SetBuild("avia_winter") elseif not TheWorld.state.iswinter and winter_skin then winter_skin = false inst.AnimState:SetBuild("avia") end end What does this mean? Well, in my anim folder i have two ZIP-Files: avia.zip and avia_winter.zip. Of course avia.lua, my character prefab, loads both assets: local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset( "ANIM", "anim/avia.zip" ), Asset( "ANIM", "anim/avia_winter.zip"), } If you want to, you can always check the mod yourself as a start. I attach it to this post. avia_packed.zip Link to comment Share on other sites More sharing options...
BakaSchwarz Posted October 15, 2018 Share Posted October 15, 2018 We all start somewhere. And since the game files aren't too good documented, it can be a bit disheartening at the start. Just ask away when something's not clear 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