Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

FrontierHero

how to make nonfood items a foodtype?

Recommended Posts

hey guys!

I've still been working on a custom mod for myself, and my character is a robot, so his eyes work as light-adjusting lenses. so i added 'night vision' to one of his perks, and the awesome people here in this community helped me add night vision to my mod!

but when I played the game, I found out applying night vision will disable damage taken from Charlie, which defeats one of Don't Starve's key purposes; don't get caught in the dark. It made the mod pretty OP, and I ultimately decided to change it to something that would still be a perk, but would not make the mod crazy easy to get through nights with.

so my character that the mod is modeled after also eats batteries...what with him being a cyborg and all. so I was wondering, is there a way to make Electrical Doodads a foodtype for the mod specifically? (those are what those battery things are called, right? electrical doodads? They resemble batteries enough for me to decided this could be a better alternative to night vision.)

I'm sure there is a way, but I've found through looking at related questions, that you have to set the item as a certain foodtype, and I have no idea what it would be, or where to even put it. do I work with the mod's own .lua files or do i work with the item's files itself?

thanks to anyone who can help me, it's very much appreciated! :)

Share this post


Link to post
Share on other sites
On 3/3/2017 at 4:41 PM, FrontierHero said:

hey guys!

I've still been working on a custom mod for myself, and my character is a robot, so his eyes work as light-adjusting lenses. so i added 'night vision' to one of his perks, and the awesome people here in this community helped me add night vision to my mod!

but when I played the game, I found out applying night vision will disable damage taken from Charlie, which defeats one of Don't Starve's key purposes; don't get caught in the dark. It made the mod pretty OP, and I ultimately decided to change it to something that would still be a perk, but would not make the mod crazy easy to get through nights with.

so my character that the mod is modeled after also eats batteries...what with him being a cyborg and all. so I was wondering, is there a way to make Electrical Doodads a foodtype for the mod specifically? (those are what those battery things are called, right? electrical doodads? They resemble batteries enough for me to decided this could be a better alternative to night vision.)

I'm sure there is a way, but I've found through looking at related questions, that you have to set the item as a certain foodtype, and I have no idea what it would be, or where to even put it. do I work with the mod's own .lua files or do i work with the item's files itself?

thanks to anyone who can help me, it's very much appreciated! :)

The best place to start would be Woodie's file since he eats wood. You would want to establish what your characters diet consists of and on the battery what type of food it is. 

From Woodie.lua

local BEAVER_DIET =
{
    FOODTYPE.WOOD,
    FOODTYPE.ROUGHAGE,
}

inst.components.eater:SetDiet(BEAVER_DIET, BEAVER_DIET)

From Twigs.lua

inst.components.edible.foodtype = FOODTYPE.ROUGHAGE

Share this post


Link to post
Share on other sites
Cherryzion    385
On 2017-03-04 at 11:10 PM, RedHairedHero said:

The best place to start would be Woodie's file since he eats wood. You would want to establish what your characters diet consists of and on the battery what type of food it is. 

From Woodie.lua

local BEAVER_DIET =
{
    FOODTYPE.WOOD,
    FOODTYPE.ROUGHAGE,
}

inst.components.eater:SetDiet(BEAVER_DIET, BEAVER_DIET)

From Twigs.lua

inst.components.edible.foodtype = FOODTYPE.ROUGHAGE

I think it would be better to look into WX's code, since he is able to eat gears by default, whereas Woodie can only eat wood while in Beaver form. 

Share this post


Link to post
Share on other sites

local function oneat(inst, food)
    if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.GEARS then
        --give an upgrade!
        inst.level = inst.level + 1
        applyupgrades(inst)
        inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")

        -- MarkL Can't do this here, need to do it inside the component
        -- todo pax Move upgrade logic elsewhere.  
        --inst.HUD.controls.status.heart:PulseGreen()
        --inst.HUD.controls.status.stomach:PulseGreen()
        --inst.HUD.controls.status.brain:PulseGreen()

        --inst.HUD.controls.status.brain:ScaleTo(1.3,1,.7)
        --inst.HUD.controls.status.heart:ScaleTo(1.3,1,.7)
        --inst.HUD.controls.status.stomach:ScaleTo(1.3,1,.7)
    end

that is WX-78's code! np

Share this post


Link to post
Share on other sites
3 hours ago, officialpinq said:

local function oneat(inst, food)
    if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.GEARS then
        --give an upgrade!
        inst.level = inst.level + 1
        applyupgrades(inst)
        inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")

        -- MarkL Can't do this here, need to do it inside the component
        -- todo pax Move upgrade logic elsewhere.  
        --inst.HUD.controls.status.heart:PulseGreen()
        --inst.HUD.controls.status.stomach:PulseGreen()
        --inst.HUD.controls.status.brain:PulseGreen()

        --inst.HUD.controls.status.brain:ScaleTo(1.3,1,.7)
        --inst.HUD.controls.status.heart:ScaleTo(1.3,1,.7)
        --inst.HUD.controls.status.stomach:ScaleTo(1.3,1,.7)
    end

that is WX-78's code! np

oh, thank you very much! this is helpful! i appreciate the help; i'll work with this and see what I can do!

Share this post


Link to post
Share on other sites