Cyde042 Posted August 19, 2014 Share Posted August 19, 2014 I'm working on a milk-able goat mod and I can't find anywhere how to add a custom stategraph to an existing mob, and by that I mean how do I declare to use it in modmain.lua or where-ever do I declare that. Also, when making a custom stategraph, do I need to copy paste all the existing one and add my own bits or simply add the bits? Thanks in advance Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/ Share on other sites More sharing options...
Heavenfall Posted August 20, 2014 Share Posted August 20, 2014 (edited) inst:SetStateGraph("SGbat") in an addprefabpostinit should do the trick if you want to do it from modmain. Otherwise just put it in the prefab file where it belongs. Edited August 20, 2014 by Heavenfall Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524629 Share on other sites More sharing options...
Cyde042 Posted August 20, 2014 Author Share Posted August 20, 2014 inst:SetStateGraph("SGbat") in an addprefabpostinit should do the trick if you want to do it from modmain. Otherwise just put it in the prefab file where it belongs. I hate to be that guy but I don't know how. This is what I have in modmain.lua, adding SetStateGraph in the function makes the game crash, but I don't know how to include it in the AddPrefabPostInit, could you help, please?PrefabFiles = { "lightninggoat",}function GoatPrefabPostInit(inst)local hair_growth_days = 2 inst:AddComponent("beard") inst.components.beard.bits = 2 inst.components.beard.daysgrowth = hair_growth_days + 1 inst.components.beard.onreset = function() inst.sg:GoToState("shaved") end inst.components.beard.canshavetest = function() if not inst.components.sleeper:IsAsleep() then return false end return true end inst.components.beard.prize = "goatmilk" inst.components.beard:AddCallback(hair_growth_days, function() if inst.components.beard.bits == 0 then inst.hairGrowthPending = true end end)endAddPrefabPostInit("lightninggoat", GoatPrefabPostInit) Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524659 Share on other sites More sharing options...
Heavenfall Posted August 20, 2014 Share Posted August 20, 2014 What does the log.txt say about your crash when you add it? Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524814 Share on other sites More sharing options...
Cyde042 Posted August 20, 2014 Author Share Posted August 20, 2014 (edited) What does the log.txt say about your crash when you add it? I don't even know what happened. It didn't crash for some reason. But it seems that it doesn't use the custom stategraph since the goats don't "regrow" the milk back. And just to clarify that I explained my problem - I have added a Stategraph in the /scripts/stategraphs folder of the mod and I want it to be used instead of the game one, along with the changes that's in my previous post. Edit: It might have crashed that because one of the goats was already harvested. Edited August 20, 2014 by Cyde042 Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524824 Share on other sites More sharing options...
Heavenfall Posted August 20, 2014 Share Posted August 20, 2014 Post the mod. Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524858 Share on other sites More sharing options...
Cyde042 Posted August 20, 2014 Author Share Posted August 20, 2014 (edited) Post the mod. http://www.filedropper.com/milkgoats You can ignore the require bits, I was just messing around. Also the parts I added in the stategraph are between 2 long lines (--------------------------), near the end. Edited August 20, 2014 by Cyde042 Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524873 Share on other sites More sharing options...
Heavenfall Posted August 20, 2014 Share Posted August 20, 2014 (edited) In modmain change inst:SetStateGraph("SGlightninggoat") to inst:SetStateGraph("SGlightninggoat2") and in SGlightninggoat2.lua change return StateGraph("lightninggoat", states, events, "idle", actionhandlers) to return StateGraph("lightninggoat2", states, events, "idle", actionhandlers) and delete SGlightninggoat.lua from your mod. Edited August 20, 2014 by Heavenfall Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524877 Share on other sites More sharing options...
Cyde042 Posted August 20, 2014 Author Share Posted August 20, 2014 In modmain change inst:SetStateGraph("SGlightninggoat") to inst:SetStateGraph("SGlightninggoat2") and in SGlightninggoat2.lua change return StateGraph("lightninggoat", states, events, "idle", actionhandlers) to return StateGraph("lightninggoat2", states, events, "idle", actionhandlers) and delete SGlightninggoat.lua from your mod. Forgot to delete the other SG, SGlightninggoat2 is the original and SGlightninggoat is the custom one Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524883 Share on other sites More sharing options...
Heavenfall Posted August 20, 2014 Share Posted August 20, 2014 Let us know if you have any other problems. Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-524898 Share on other sites More sharing options...
Cyde042 Posted August 21, 2014 Author Share Posted August 21, 2014 (edited) Let us know if you have any other problems. I mean there is no lightninggoat2. I still get crashes even if I change the name of the stategraph in the function. Edit: Talk about a rookie's mistake, I didn't set up a proper directory. Forgot to make a script folder. Anyway the stategraph seems to be working, but the milk doesn't grow back for some reason, or maybe goats aren't affected by time like a crockpot. I'll keep experimenting. Edit2: The stategraph is fine, the animations work. What doesn't seem to work is the Callback function in the modmain. Edit3: Got to make it work, finally. Had to add another line in the idle stat that responds to GrowthPending. Edited August 21, 2014 by Cyde042 Link to comment https://forums.kleientertainment.com/forums/topic/39498-helpdeclare-usage-of-a-custom-stategraph-to-a-vanilla-mob/#findComment-525167 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