Ciro2106 Posted July 26, 2022 Share Posted July 26, 2022 The DST Mod Character that im doing is a dream demon, so i want to make nightmare fuel edible , flowers are they hate. How do I get my character to eat that? :"3 Link to comment https://forums.kleientertainment.com/forums/topic/142110-how-do-i-get-my-character-to-eat-nightmare-fuel/ Share on other sites More sharing options...
w00tyd00d Posted July 26, 2022 Share Posted July 26, 2022 In your modmain: local FOODTYPE = GLOBAL.FOODTYPE FOODTYPE.NM_FUEL = "NM_FUEL" function EaterCompPostInit(comp) comp.SetCanEatNightmareFuel = function(self) table.insert(self.preferseating, FOODTYPE.NM_FUEL) table.insert(self.caneat, FOODTYPE.NM_FUEL) self.inst:AddTag(FOODTYPE.NM_FUEL.."_eater") end end AddComponentPostInit("eater", EaterCompPostInit) function NightmareFuelPrefabPostInit(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("edible") inst.components.edible.foodtype = FOODTYPE.NM_FUEL -- OPTIONAL STAT NUMBERS --inst.components.edible.healthvalue = ## --inst.components.edible.hungervalue = ## --inst.components.edible.sanityvalue = ## -- OPTIONAL CALLBACK SETUP -- inst.components.edible:SetOnEatenFn() end end AddPrefabPostInit("nightmarefuel", NightmareFuelPrefabPostInit) and then in your character prefab somewhere underneath the ismastersim check: inst.components.eater:SetCanEatNightmareFuel() That will at least make it so Nightmare Fuel is edible only to your character, as well as give you access to adding in any food stats you want for nightmare fuel or if you want it to have a callback upon being eaten. If I understand your request right, you also want your character hate eating flowers? And if that's so, all you'd need is add a simple wrapper inside of the EaterCompPostInit function like this: -- Inside EaterCompPostInit local _PrefersToEat = comp.PrefersToEat comp.PrefersToEat = function(self, food) if (food.prefab == "petals" or food.prefab == "petals_evil") and self.inst.prefab == "YOUR_CHARACTER" then return false end return _PrefersToEat(self, food) end And you should be all set from there I had to do something similar with my Repair mod to get WX to be able to eat my mod's batteries, so luckily I was already familiar with how to do it lol 1 Link to comment https://forums.kleientertainment.com/forums/topic/142110-how-do-i-get-my-character-to-eat-nightmare-fuel/#findComment-1588773 Share on other sites More sharing options...
Ciro2106 Posted July 27, 2022 Author Share Posted July 27, 2022 On 7/25/2022 at 11:34 PM, w00tyd00d said: In your modmain: local FOODTYPE = GLOBAL.FOODTYPE FOODTYPE.NM_FUEL = "NM_FUEL" function EaterCompPostInit(comp) comp.SetCanEatNightmareFuel = function(self) table.insert(self.preferseating, FOODTYPE.NM_FUEL) table.insert(self.caneat, FOODTYPE.NM_FUEL) self.inst:AddTag(FOODTYPE.NM_FUEL.."_eater") end end AddComponentPostInit("eater", EaterCompPostInit) function NightmareFuelPrefabPostInit(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("edible") inst.components.edible.foodtype = FOODTYPE.NM_FUEL -- OPTIONAL STAT NUMBERS --inst.components.edible.healthvalue = ## --inst.components.edible.hungervalue = ## --inst.components.edible.sanityvalue = ## -- OPTIONAL CALLBACK SETUP -- inst.components.edible:SetOnEatenFn() end end AddPrefabPostInit("nightmarefuel", NightmareFuelPrefabPostInit) and then in your character prefab somewhere underneath the ismastersim check: inst.components.eater:SetCanEatNightmareFuel() That will at least make it so Nightmare Fuel is edible only to your character, as well as give you access to adding in any food stats you want for nightmare fuel or if you want it to have a callback upon being eaten. If I understand your request right, you also want your character hate eating flowers? And if that's so, all you'd need is add a simple wrapper inside of the EaterCompPostInit function like this: -- Inside EaterCompPostInit local _PrefersToEat = comp.PrefersToEat comp.PrefersToEat = function(self, food) if (food.prefab == "petals" or food.prefab == "petals_evil") and self.inst.prefab == "YOUR_CHARACTER" then return false end return _PrefersToEat(self, food) end And you should be all set from there I had to do something similar with my Repair mod to get WX to be able to eat my mod's batteries, so luckily I was already familiar with how to do it lol this notified me so late , swwy! i have an error saying this: btw, im new in all of this and also english its not my main ;w; Link to comment https://forums.kleientertainment.com/forums/topic/142110-how-do-i-get-my-character-to-eat-nightmare-fuel/#findComment-1589441 Share on other sites More sharing options...
w00tyd00d Posted July 27, 2022 Share Posted July 27, 2022 Did you make sure to put inst.components.eater:SetCanEatNightmareFuel() in your character prefab and not your modmain? Make sure its in your character's prefab file somewhere inside the master_postinit function Link to comment https://forums.kleientertainment.com/forums/topic/142110-how-do-i-get-my-character-to-eat-nightmare-fuel/#findComment-1589449 Share on other sites More sharing options...
Ciro2106 Posted July 28, 2022 Author Share Posted July 28, 2022 21 minutes ago, w00tyd00d said: Did you make sure to put inst.components.eater:SetCanEatNightmareFuel() in your character prefab and not your modmain? Make sure its in your character's prefab file somewhere inside the master_postinit function OH RIGHT! NOW IT WORKS!:D TYSMMM YOU SAVED MY DAY AND MAKE MY HAPPYYYY<333 1 Link to comment https://forums.kleientertainment.com/forums/topic/142110-how-do-i-get-my-character-to-eat-nightmare-fuel/#findComment-1589452 Share on other sites More sharing options...
w00tyd00d Posted July 28, 2022 Share Posted July 28, 2022 Glad it worked for you! haha Link to comment https://forums.kleientertainment.com/forums/topic/142110-how-do-i-get-my-character-to-eat-nightmare-fuel/#findComment-1589454 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