IntensuwweSoois Posted April 9, 2015 Share Posted April 9, 2015 ModMain: FOODGROUP = GLOBAL.FOODGROUP-- Make the food groupFOODGROUP.OMNI_NOMEAT = { name = "OMNI_NOMEAT", types = { FOODTYPE.VEGGIE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.GENERIC, }}AddComponentPostInit("eater", function(inst) function inst:SetOmnivore_NoMeat() self.foodprefs = { FOODGROUP.OMNI_NOMEAT } endend)Char prefab:inst.components.eater:SetOmnivore_NoMeat()local Omni_NoMeat = { name = "OMNI_NOMEAT", types = { FOODTYPE.VEGGIE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.GENERIC, }} inst.components.eater.foodprefs = { Omni_NoMeat }Mod is crashing when running my char, works fine with normal DSTAnything obvious im missing? thanks! Link to comment Share on other sites More sharing options...
DarkXero Posted April 9, 2015 Share Posted April 9, 2015 It crashes because you didn't put FOODTYPE = GLOBAL.FOODTYPE. Also, this won't work because there isn't a foodprefs variable used on RoG eater. For RoG, what you want is:a) in modmain.luaFOODGROUP = GLOBAL.FOODGROUPFOODTYPE = GLOBAL.FOODTYPEFOODGROUP.OMNI_NOMEAT = { name = "OMNI_NOMEAT", types = { FOODTYPE.VEGGIE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.GENERIC }}b) in your character's prefabinst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT}) Link to comment Share on other sites More sharing options...
IntensuwweSoois Posted April 9, 2015 Author Share Posted April 9, 2015 It crashes because you didn't put FOODTYPE = GLOBAL.FOODTYPE. Also, this won't work because there isn't a foodprefs variable used on RoG eater. For RoG, what you want is:a) in modmain.luaFOODGROUP = GLOBAL.FOODGROUPFOODTYPE = GLOBAL.FOODTYPEFOODGROUP.OMNI_NOMEAT = { name = "OMNI_NOMEAT", types = { FOODTYPE.VEGGIE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.GENERIC }}b) in your character's prefabinst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT})Thanks! Works 100% in RoG, but not normal dst. Is there a way I can check for Rog installation? Link to comment Share on other sites More sharing options...
DarkXero Posted April 9, 2015 Share Posted April 9, 2015 (edited) if SEASONS.SPRING then inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT})else inst.components.eater.foodprefs = {FOODGROUP.OMNI_NOMEAT}endin your character's prefab. Edited April 9, 2015 by DarkXero Link to comment Share on other sites More sharing options...
IntensuwweSoois Posted April 9, 2015 Author Share Posted April 9, 2015 if SEASONS.SPRING then inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT})else inst.components.eater.foodprefs = {FOODGROUP.OMNI_NOMEAT}endin your character's prefab. How do I init the GLOBAL varaible, crashing when IG Link to comment Share on other sites More sharing options...
DarkXero Posted April 9, 2015 Share Posted April 9, 2015 (edited) To get a global variable, writing in modmain, you put GLOBAL.variable.In prefabs or components, you are in the global environment, so no global needed. In modmain, it would end like this:FOODGROUP = GLOBAL.FOODGROUPFOODTYPE = GLOBAL.FOODTYPESEASONS = GLOBAL.SEASONS FOODGROUP.OMNI_NOMEAT = { name = "OMNI_NOMEAT", types = { FOODTYPE.VEGGIE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.GENERIC }}AddPrefabPostInit("walter", function(inst) if SEASONS.SPRING then inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT}) else inst.components.eater.foodprefs = {FOODGROUP.OMNI_NOMEAT} endend)And crashing when what? Edited April 9, 2015 by DarkXero Link to comment Share on other sites More sharing options...
IntensuwweSoois Posted April 14, 2015 Author Share Posted April 14, 2015 To get a global variable, writing in modmain, you put GLOBAL.variable.In prefabs or components, you are in the global environment, so no global needed. In modmain, it would end like this:FOODGROUP = GLOBAL.FOODGROUPFOODTYPE = GLOBAL.FOODTYPESEASONS = GLOBAL.SEASONS FOODGROUP.OMNI_NOMEAT = { name = "OMNI_NOMEAT", types = { FOODTYPE.VEGGIE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.GENERIC }}AddPrefabPostInit("walter", function(inst) if SEASONS.SPRING then inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT}) else inst.components.eater.foodprefs = {FOODGROUP.OMNI_NOMEAT} endend)And crashing when what? Never mind, had a silly error on my side. Thanks again Link to comment Share on other sites More sharing options...
Maris Posted April 15, 2015 Share Posted April 15, 2015 Thanks God, "if SEASONS.SPRING then" will be deprecated soon. Link to comment Share on other sites More sharing options...
SenL Posted April 22, 2015 Share Posted April 22, 2015 (edited) I just got the DST:RoG update and I need to fix Groot. I see that eater component no longer has "foodprefs".I tried to figure out from DarkXero codes above but couldn't. Goal: Groot can eat following:"twigs", "log", "boards", "petals", "petals_evil", "pinecone", "cutgrass", "foliage", "cutlichen", "livinglog" Current code:modmainGLOBAL.FOODTYPE.GROOTFOOD = "GROOTFOOD"local groot_food = {"twigs", "log", "boards", "petals", "petals_evil", "pinecone", "cutgrass", "foliage", "cutlichen", "livinglog"}local function AddGrootFood(inst) inst:AddTag("edible_"..GLOBAL.FOODTYPE.GROOTFOOD)endfor k,v in pairs(groot_food) do AddPrefabPostInit(v, AddGrootFood)end gggrootinst.components.eater.foodprefs = { FOODTYPE.GROOTFOOD } Edit:Nm, I found it. Added below on modmainGLOBAL.FOODGROUP.GROOT_FOODGROUP = { name = "GROOT_FOODGROUP" ,types = { GLOBAL.FOODTYPE.GROOTFOOD, }} And change this on the gggroot:--inst.components.eater.foodprefs = { FOODTYPE.GROOTFOOD }inst.components.eater:SetDiet({FOODGROUP.GROOT_FOODGROUP}) Thanks. Edited April 22, 2015 by SenL 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