Jump to content

Recommended Posts

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

  • Like 1
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:
image.thumb.png.12750a14df0543ef431fbb300e39809b.png
btw, im new in all of this and also english its not my main ;w;
 

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:wilson_love:

  • Like 1

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
×
  • Create New...