Jump to content

Which prefabs are considered foodtype=WOOD?


Recommended Posts

1)

How do I search to find what prefabs are considered foodtype x (replace x with what you want, like wood)

without searching in files? (I use notepadd++)

 

2)

When I open twigs.lua (scripts\prefabs), I see that it's food type of wood and that it is edible, but how do I know its food value (health, hunger, sanity)? It's not in the lua.

 

Thanks.

Link to comment
Share on other sites

Ok thanks, but how about cutgrass ... the original cutgrass.lua doesn't have nutrition value in it but char mod "Wark" has it customized - BUT it has these:

 

inst.components.edible.oneaten = function(inst, eater)
    if eater.prefab == "wark" then
        eater.components.health:DoDelta(-5)
        eater.components.hunger:DoDelta(-4) 
        eater.components.sanity:DoDelta(0)
    end
 
I'm quite sure the creator didn't mean to take away 5 health and 4 hunger when eating cutgrass. It should be at least adding 1 hunger (which is the point of eating it).
So where's the original cutgrass nutrition value?
Link to comment
Share on other sites

1)

How come when I add this below to modmain.lua, I can eat cutgrass but it's acting weird.

Example. My hunger is 149, I eat cutgrass and it went down to 140.

My hunger is 141, eating it = back to 140.

What the?

local function cutgrassEat(inst)	inst.components.edible.oneaten = function(inst, eater)		if eater.prefab == "grassman" then			eater.components.health:DoDelta(-8) --1 or 2?			eater.components.hunger:DoDelta(-10) --10-10 = 0			eater.components.sanity:DoDelta(0)		end	endendAddPrefabPostInit("cutgrass", cutgrassEat)

2)

I have "Display food value" mod and it still says health 10 hunger 10 even though it's not. (cutgrass)

How do I remedy this...

Link to comment
Share on other sites

@SenL, That's because it's applying the innate cutgrass 10 hunger first, bringing you to 150, then running your oneaten, subtracting 10. I'd override the inst.components.eater:Eat function in your character's prefab to check for grass and then modify its stats before calling the original Eat function.

 

And DFV shows 10 hunger 10 health because that's what the cutgrass prefab has. DFV is just checking healthvalue and hungervalue, it has no way to find stray DoDeltas.

Link to comment
Share on other sites

Is it like this...

 

local oldEater = inst.components.Eater.Eat
inst.components.eater.eat = function(inst)
if inst.prefab == "cutgrass" then
inst.components.edible.healthvalue = 2
inst.components.edible.hungervalue = 0
inst.components.edible.sanityvalue = 0
end
oldEater(food)
end
 
Not so sure about the "oldEater(food)" part...
Also do I put that in common_postinit or master_postinit inside mychar.lua?
 
Thanks rezecib.
 
Edit:
Nope, it crashed here:
[00:07:45]: [string "../mods/DST_Groot/scripts/prefabs/grassman.l..."]:134: attempt to index field 'Eater' (a nil value)
 
Edit:
Found this
 
Studying it...

Edit:
Now it doesn't crash but it doesn't do it right either.
 
local oldEater = inst.components.eater.Eat
inst.components.eater.Eat = function(self, food)
if self:CanEat(food) and food.prefab == "cutgrass" then
food.components.edible.healthvalue = 2
food.components.edible.hungervalue = 0
food.components.edible.sanityvalue = 0
end
return oldEater(self, food)
end
 
It displays health 10 hunger 10 at first. Then once eaten, it displays health 2.
However, eating it doesn't add anything to health, hunger or sanity.

 

Edit:

Nevermind, it seems to work again. I probably had godmode on lol.

Question: does this cutgrass now give +2 to only mychar, or to all others (who are able to eat cutgrass)?

Edited by SenL
Link to comment
Share on other sites

Your issues before were because you were using pretty random capitalization. Variable names are case-sensitive, if something is declared as "eater" you have to use "eater", not "Eater".

 

Question: does this cutgrass now give +2 to only mychar, or to all others (who are able to eat cutgrass)?
 It should only give it to your character. However, thinking about it now, it might behave strangely with stacks (e.g. changing the values for the whole stack when one is eaten from the stack). You could add a part where you check if the food has a stackable component, and if the stacksize is greater than 1, save the current values, then replace them after calling the old Eat function.

 

But yes, I don't think any character-specific approach will ever be fully compatible with Display Food Values. Just trying to think of one that might... Maybe if you have the item listen for entering/leaving the inventory, changing the values then. With that, you will probably need a special case to handle when your character feeds another or vice-versa, though.

Link to comment
Share on other sites

if I want my character can eat nightmare fuel to upgrades just like wx78 can eat gear to upgrades what should I do

i have try this

 

 

local function applyupgrades(inst)
  local  = math.min(inst.Soul,)
inst.components.combat.damagemultiplier = math.ceil(0.7 + inst.upgrades * (0.1))
inst.components.talker:Say("Soul_Collect : ".. (inst.Soul))
end
local function oneat(inst, food)
if food and food.components.edible and food.components.edible.food.prefab == "nightmarefuel" then
--give an upgrade!
inst.Soul = inst.Soul + 1
applyupgrades(inst)
inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")
end
end
local function onpreload(inst, data)
if data then
if data.Soul then
inst.Soul = data.Soul
applyupgrades(inst)
--re-set these from the save data, because of load-order clipping issues
if data.damagemultiplier and data.damagemultiplier.damagemultiplier then inst.components.combat.damagemultiplier.currentdamagemultiplier = data.damagemultiplier.damagemultiplier end
inst.components.combat.damagemultiplier :DoDelta(0)
end
end
 end
local function onsave(inst, data)
data.level = inst.Soul
data.charge_time = inst.charge_time
end
-- This initializes for both clients and the host
local common_postinit = function(inst) 
-- Minimap icon
inst.MiniMapEntity:SetIcon( "esctemplate.tex" )
end
-- This initializes for the host only
local master_postinit = function(inst)
-- choose which sounds this character will play
inst.soundsname = "willow"
inst.components.eater:SetCanEatNightmarefuel()
inst.components.eater:SetOnEatFn(oneat)
applyupgrades(inst)
-- Stats
inst.components.health:SetMaxHealth(150)
inst.components.hunger:SetMax(150)
inst.components.sanity:SetMax(200)
end

 

 

Result:..........crash when enable this mod i didn't make my own character now i had use that Extended Sample Character mod as my model now

PS: im noob :3

esctemplate.lua

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