Jump to content

How to make a custom food type and make it only diet?


Recommended Posts

I know how to make a food item (only craftable) but i don't know how to make a  custom food type(diet) and i don't know how to make it only diet for custom character. I checked food tutorial but there was nothign about food type(or i miss it). It would be great if anyone have an example or tutorial for it.

Link to comment
Share on other sites

if you check the constants.lua right under the scripts folder, you'll find a list of existing food types. and if you check the eater component, it has a series of functions - confusing enough for me - that includes AbleToEat, CanEat, PrefersToEat, and the like, these functions check whether or not the food type is included in the list of food types that make up the player's diet. i would imagine it would be as simple as 1) adding it to the list of foodtypes under constants.lua and then 2) making your custom character only able to eat this food type and 3) don't forget to add the food type to the diets of other players or mobs - if that's what you want - so they can eat it too.

Link to comment
Share on other sites

FOODTYPE =
{
    GENERIC = "GENERIC",
    MEAT = "MEAT",
    VEGGIE = "VEGGIE",
    ELEMENTAL = "ELEMENTAL",
    GEARS = "GEARS",
    HORRIBLE = "HORRIBLE",
    INSECT = "INSECT",
    SEEDS = "SEEDS",
    BERRY = "BERRY", --hack for smallbird; berries are actually part of veggie
    RAW = "RAW", -- things which some animals can eat off the ground, but players need to cook
    BURNT = "BURNT", --For lavae.
    ROUGHAGE = "ROUGHAGE",
	WOOD = "WOOD",
    GOODIES = "GOODIES",
    MONSTER = "MONSTER", -- Added in for woby, uses the secondary foodype originally added for the berries
}

so you mean its ok if i just add local FOODTYPE = { CUSTOM_FOODTYPE = "CUSTOM_FOODTYPE"} in modmain and in food.lua 

inst.components.edible.foodtype = "CUSTOM_FOODTYPE"

and same for diet?

Edited by AkaiNight
Link to comment
Share on other sites

i would think that you should insert the food type into the table of the constants, so:

GLOBAL.FOODTYPES.MYFOODTYPE = "MYFOODTYPE" 
-- and then, in the player prefab file 
inst.components.eater.caneat = {FOODTYPES.MYFOODTYPE}
inst.componetns.eater.preferseating = {FOODTYPES.MYFOODTYPE}

 

  • Thanks 1
Link to comment
Share on other sites

15 hours ago, Bad Willow said:

i would think that you should insert the food type into the table of the constants, so:


GLOBAL.FOODTYPES.MYFOODTYPE = "MYFOODTYPE" 
-- and then, in the player prefab file 
inst.components.eater.caneat = {FOODTYPES.MYFOODTYPE}
inst.componetns.eater.preferseating = {FOODTYPES.MYFOODTYPE}

 

oh i see thanks. And i assume i can add "inst.components.eater.caneat" as much as i like.

  • Ninja 1
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...