Jump to content

Mod character vegeterian issue with DST RoG


Recommended Posts

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 DST
Anything obvious im missing? thanks!

Link to comment
Share on other sites

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.lua

FOODGROUP = GLOBAL.FOODGROUPFOODTYPE = GLOBAL.FOODTYPEFOODGROUP.OMNI_NOMEAT = {	name = "OMNI_NOMEAT",	types = {		FOODTYPE.VEGGIE,		FOODTYPE.INSECT,		FOODTYPE.SEEDS,		FOODTYPE.GENERIC	}}

b) in your character's prefab

inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT})
Link to comment
Share on other sites

 

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.lua

FOODGROUP = GLOBAL.FOODGROUPFOODTYPE = GLOBAL.FOODTYPEFOODGROUP.OMNI_NOMEAT = {	name = "OMNI_NOMEAT",	types = {		FOODTYPE.VEGGIE,		FOODTYPE.INSECT,		FOODTYPE.SEEDS,		FOODTYPE.GENERIC	}}

b) in your character's prefab

inst.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

if SEASONS.SPRING then   inst.components.eater:SetDiet({FOODGROUP.OMNI}, {FOODGROUP.OMNI_NOMEAT})else   inst.components.eater.foodprefs = {FOODGROUP.OMNI_NOMEAT}end

in your character's prefab.

Edited by DarkXero
Link to comment
Share on other sites

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 by DarkXero
Link to comment
Share on other sites

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

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:

modmain

GLOBAL.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)
end
for k,v in pairs(groot_food) do
    AddPrefabPostInit(v, AddGrootFood)
end
 
gggroot
inst.components.eater.foodprefs = { FOODTYPE.GROOTFOOD }
 
Edit:
Nm, I found it.
 
Added below on modmain
GLOBAL.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 by SenL
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...