SenL Posted January 29, 2015 Share Posted January 29, 2015 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 More sharing options...
Jjmarco Posted January 29, 2015 Share Posted January 29, 2015 @SenL 1) Well, I don't see any easier way of finding that other than using Notepad++'s handy Find in files function. 2) I think that's because twigs aren't actually edible in game, so they didn't define any nutritional values. Link to comment Share on other sites More sharing options...
Kzisor Posted January 29, 2015 Share Posted January 29, 2015 @SenL, FOODTYPE.WOOD is only used for Woodies werebeaver form. They don't have a nutrition value they only affect his beaveriness value. Link to comment Share on other sites More sharing options...
SenL Posted January 29, 2015 Author Share Posted January 29, 2015 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 More sharing options...
Kzisor Posted January 29, 2015 Share Posted January 29, 2015 @SenL, I cannot say why the creator of Work did as such, all I can say is that cutgrass is the same as twigs and other FOODTYPE.WOOD. The creator could have added those nutrition values themselves. Link to comment Share on other sites More sharing options...
rezecib Posted January 30, 2015 Share Posted January 30, 2015 @SenL, It uses the default hunger value and health value of 10. Link to comment Share on other sites More sharing options...
SenL Posted January 30, 2015 Author Share Posted January 30, 2015 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 More sharing options...
rezecib Posted January 30, 2015 Share Posted January 30, 2015 @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 More sharing options...
SenL Posted January 30, 2015 Author Share Posted January 30, 2015 (edited) Is it like this... local oldEater = inst.components.Eater.Eatinst.components.eater.eat = function(inst)if inst.prefab == "cutgrass" theninst.components.edible.healthvalue = 2inst.components.edible.hungervalue = 0inst.components.edible.sanityvalue = 0endoldEater(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 thishttp://forums.kleientertainment.com/topic/49607-removing-bad-effects-from-mushroom-for-my-characters/?hl=eater#entry606114 Studying it...Edit:Now it doesn't crash but it doesn't do it right either. local oldEater = inst.components.eater.Eatinst.components.eater.Eat = function(self, food)if self:CanEat(food) and food.prefab == "cutgrass" thenfood.components.edible.healthvalue = 2food.components.edible.hungervalue = 0food.components.edible.sanityvalue = 0endreturn 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 January 30, 2015 by SenL Link to comment Share on other sites More sharing options...
rezecib Posted January 31, 2015 Share Posted January 31, 2015 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 More sharing options...
VikeSlash Posted February 1, 2015 Share Posted February 1, 2015 If you're doing this for Woodie in DST, he was just released today Link to comment Share on other sites More sharing options...
ArCraMiCia Posted February 4, 2015 Share Posted February 4, 2015 if I want my character can eat nightmare fuel to upgrades just like wx78 can eat gear to upgrades what should I doi 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))endlocal 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 + 1applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")endendlocal function onpreload(inst, data)if data thenif data.Soul theninst.Soul = data.Soulapplyupgrades(inst)--re-set these from the save data, because of load-order clipping issuesif data.damagemultiplier and data.damagemultiplier.damagemultiplier then inst.components.combat.damagemultiplier.currentdamagemultiplier = data.damagemultiplier.damagemultiplier endinst.components.combat.damagemultiplier :DoDelta(0)endend endlocal function onsave(inst, data)data.level = inst.Souldata.charge_time = inst.charge_timeend-- This initializes for both clients and the hostlocal common_postinit = function(inst) -- Minimap iconinst.MiniMapEntity:SetIcon( "esctemplate.tex" )end-- This initializes for the host onlylocal master_postinit = function(inst)-- choose which sounds this character will playinst.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 nowPS: im noob :3esctemplate.lua 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