ArCraMiCia Posted February 12, 2015 Share Posted February 12, 2015 hello again..... my last problem is fixed the cause is...... I forgot to put "if" in function oneat (facepalm :3)now my character can go into chraracter select scene but... when i select my character and get to the worldit crash againI want my character perk is can eat nightmare fuel to level up so i try to copy prefap of WX78 like this...... local master_postinit = function(inst)-- choose which sounds this character will playinst.level = 0inst.components.eater:SetOnEatFn(oneat)inst.components.eater:SetCanEatNightmarefuel()applyupgrades(inst)inst.soundsname = "willow"-- Stats inst.components.health:SetMaxHealth(150)inst.components.hunger:SetMax(150)inst.components.sanity:SetMax(200)end..it doesn' work......here log file...log.txt Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/ Share on other sites More sharing options...
Pyrobolser Posted February 12, 2015 Share Posted February 12, 2015 (edited) Hello !!First you have to make the prefab "nightmarefuel" edible ! Copy the prefab nightmarefuel.lua in your mod and add the following : --------------------- Mod edition : inst:AddComponent("edible") inst.components.edible.foodtype = FOODTYPE.HORRIBLE inst.components.edible.oneaten = function(inst, eater) if eater.prefab == "yourcharacter" then eater.components.health:DoDelta(x) eater.components.hunger:DoDelta(y) eater.components.sanity:DoDelta(z) endend --------------------- End of mod editionDon't forget to change "yourcharacter" with the name of your character (but keep the " " ). And x, y and z with the correct values (can be negative if you want). Now you have to create a custom food type for your character, in the modmain.lua. You can use the code from my mod "Hulot the Grumpy Owl" :local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGSlocal Eater = require "components/eater"local Text = require "widgets/text"local Image = require "widgets/image"-- Create foodtype 'Owlfood'GLOBAL.FOODTYPE.OWLFOOD = "OWLFOOD"local owl_food = {"bee", "butterfly", "fireflies", "mosquito", }local function AddOwlFood(inst) inst:AddTag("edible_"..GLOBAL.FOODTYPE.OWLFOOD)endfor k,v in pairs(owl_food) do AddPrefabPostInit(v, AddOwlFood)endchange owlfood with your custom foodtype's name. And the name of the prefabs with all the edibles items you want your character to eat. Finally, on your character's prefab :inst.components.eater.foodprefs = { FOODTYPE.OWLFOOD, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.MEAT, FOODTYPE.GENERIC, }You can add all the foodtypes your character eats. Again this is from my mod, try to adapt the name so it matches what you did in the modmain.lua. It should work, now. I know there are some cleaner ways to make the food edible. But I am a beginner in lua =)Hope it helps. Pyrobolser Edited February 12, 2015 by Pyrobolser Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-612326 Share on other sites More sharing options...
rezecib Posted February 12, 2015 Share Posted February 12, 2015 Copy the prefab nightmarefuel.lua in your mod and add the following Actually, copying the file and editing it a little is bad practice. It will make your mod incompatible with any other mod that does the same. Instead, you should modify it with a PrefabPostInit. Also, since you're making your own foodtype for it, it's better to just assign normal edible values to it instead of writing DoDeltas into the oneaten, because no other characters would have that foodtype anyway. So in this case, put this in the modmain:AddPrefabPostInit("nightmarefuel", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.HORRIBLE inst.components.edible.healthvalue = x inst.components.edible.sanityvalue = y inst.components.edible.hungervalue = zendAnd a little more clarification on the above, once you make your foodtype, for example DARKFOOD, you'd replace the GLOBAL.FOODTYPE.HORRIBLE there with GLOBAL.FOODTYPE.DARKFOOD. Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-612437 Share on other sites More sharing options...
Pyrobolser Posted February 13, 2015 Share Posted February 13, 2015 Yes, this is the "cleaner way" i was talking about.Thx rezecib, i'll use this on my mods from now =) Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-612669 Share on other sites More sharing options...
Maris Posted February 14, 2015 Share Posted February 14, 2015 To make item edible:1) Add "edible" component to item2) Set food type.3) Set food values.4) There should be "eater" component on charater (exists by default)5) Add this food type to foodprefs of "eater" component. For example, characters can't eat "HORRIBLE" food, but pigmans are able to eat it. Robots can eat "GEARS" type of food etc. For some animals there should be "bait" component. Actually 1-3 steps can be skipped and replaced by adding "edible_FOODTYPE" tag, but it's a little bit dirty hack. Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-612866 Share on other sites More sharing options...
ArCraMiCia Posted February 15, 2015 Author Share Posted February 15, 2015 (edited) pyrobolser thx that work!! but it have a problem when i exit and come back to play my level has resetsorry for being late :3 Edited February 15, 2015 by ArCraMiCia Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-613391 Share on other sites More sharing options...
Pyrobolser Posted February 15, 2015 Share Posted February 15, 2015 Try to add a "OnSave" function that saves your current level when you save the game (or exit the game). And a "OnLoad" function that loads your level. I think there are similar functions with the robot character. Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-613430 Share on other sites More sharing options...
kurioshopp Posted March 6, 2015 Share Posted March 6, 2015 So I am trying to make a mod character that can eat gears and upgrade, but I can't get this stuff to work for me. What do I do to make my character eat gears and upgrade? Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-619666 Share on other sites More sharing options...
SenL Posted March 6, 2015 Share Posted March 6, 2015 @kurioshopp Take a look at wx78 and also post your lua and/or log. Oh and create your own forum thread instead Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-619702 Share on other sites More sharing options...
Darkly67 Posted May 18, 2015 Share Posted May 18, 2015 so i have been trying what you guys have been saying but when i run the game it will quit before the game actually starts. the only thing that i added to my character was: inst.components.eater.foodprefs = {FOODTYPE.ELEMENTAL,} when i remove it, its runs just fine any ideas? Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-638450 Share on other sites More sharing options...
DarkXero Posted May 18, 2015 Share Posted May 18, 2015 @Darkly67, you must be putting that outside the master_postinit.Or playing as client and having that in common_postinit. Not to mention modifying foodprefs doesn't change anything in DST now. Link to comment https://forums.kleientertainment.com/forums/topic/50861-how-to-make-character-can-eat-something-that-doesnt-eat-like-nightmare-fuel/#findComment-638485 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