Jump to content

Recommended Posts

Copy paste into modmain.lua:

-- Fuel eating
local ACTIONS = GLOBAL.ACTIONS
local ActionHandler = GLOBAL.ActionHandler

-- Tags nightmare fuel to be eaten
local function MakeDelicious(inst)
	inst:AddTag("nightmare_flavor")
end
AddPrefabPostInit("nightmarefuel", MakeDelicious)

-- Effect of eating fuel
local function OnFuelEat(inst)
	inst.components.health:DoDelta(40)
	inst.components.hunger:DoDelta(75)
	inst.components.sanity:DoDelta(5)
end
local function FuelEater(self)
	if self.inst:HasTag("nightmare_lover") then
		self.inst:ListenForEvent("fueled_up", OnFuelEat)
	end
end
AddComponentPostInit("eater", FuelEater)

-- Action of eating fuel
local function ProcessFuel(act)
	if act.doer and act.doer:HasTag("nightmare_lover") then
		local obj = act.target or act.invobject
		if obj and obj:HasTag("nightmare_flavor") then
			if obj.components.stackable then
				obj.components.stackable:Get():Remove()
			else
				obj:Remove()
			end
			act.doer:PushEvent("fueled_up")
			return true
		end
	end
end
AddAction("PROCESSFUEL", "Eat", ProcessFuel)

-- Lets fuel get a Eat prompt on inventory
local function FuelPrompt(inst, doer, actions)
	if inst and inst:HasTag("nightmare_flavor") then
		if doer and doer:HasTag("nightmare_lover") then
			table.insert(actions, ACTIONS.PROCESSFUEL)
		end
	end
end
AddComponentAction("INVENTORY", "inspectable", FuelPrompt)

-- Looks like the player eats meat
local processhandler = ActionHandler(ACTIONS.PROCESSFUEL, "eat")
AddStategraphActionHandler("wilson", processhandler)
AddStategraphActionHandler("wilson_client", processhandler)

Then, in the common_postinit of your character, add the tag:

inst:AddTag("nightmare_lover")

 

58 minutes ago, DarkXero said:

Copy paste into modmain.lua:


-- Fuel eating
local ACTIONS = GLOBAL.ACTIONS
local ActionHandler = GLOBAL.ActionHandler

-- Tags nightmare fuel to be eaten
local function MakeDelicious(inst)
	inst:AddTag("nightmare_flavor")
end
AddPrefabPostInit("nightmarefuel", MakeDelicious)

-- Effect of eating fuel
local function OnFuelEat(inst)
	inst.components.health:DoDelta(40)
	inst.components.hunger:DoDelta(75)
	inst.components.sanity:DoDelta(5)
end
local function FuelEater(self)
	if self.inst:HasTag("nightmare_lover") then
		self.inst:ListenForEvent("fueled_up", OnFuelEat)
	end
end
AddComponentPostInit("eater", FuelEater)

-- Action of eating fuel
local function ProcessFuel(act)
	if act.doer and act.doer:HasTag("nightmare_lover") then
		local obj = act.target or act.invobject
		if obj and obj:HasTag("nightmare_flavor") then
			if obj.components.stackable then
				obj.components.stackable:Get():Remove()
			else
				obj:Remove()
			end
			act.doer:PushEvent("fueled_up")
			return true
		end
	end
end
AddAction("PROCESSFUEL", "Eat", ProcessFuel)

-- Lets fuel get a Eat prompt on inventory
local function FuelPrompt(inst, doer, actions)
	if inst and inst:HasTag("nightmare_flavor") then
		if doer and doer:HasTag("nightmare_lover") then
			table.insert(actions, ACTIONS.PROCESSFUEL)
		end
	end
end
AddComponentAction("INVENTORY", "inspectable", FuelPrompt)

-- Looks like the player eats meat
local processhandler = ActionHandler(ACTIONS.PROCESSFUEL, "eat")
AddStategraphActionHandler("wilson", processhandler)
AddStategraphActionHandler("wilson_client", processhandler)

Then, in the common_postinit of your character, add the tag:


inst:AddTag("nightmare_lover")

 

now would it be possible to add nightmare fuel to the meat category along with this

5 minutes ago, DarkXero said:

What do you mean, "category"?

You want to make everybody eat nightmare fuel like it is meat?

no i only want to be able to eat it i just want it to go in that food category for my character sense i'm planing on making my character only eat meat

7 minutes ago, GreatSound said:

no i only want to be able to eat it i just want it to go in that food category for my character sense i'm planing on making my character only eat meat

Then make it eat meat.

The code I provided makes you eat fuel regardless of diet.

19 minutes ago, GreatSound said:

One more thing though can you make the garland hat infinite for my character

AddPrefabPostInit("flowerhat", function(inst)
	if inst.components.perishable then
		inst:ListenForEvent("equipped", function(inst, data)
			local owner = data and data.owner
			if owner and owner.prefab == "wilson" then
				inst.components.perishable.updatetask:Cancel()
				inst.components.perishable.updatetask = nil
			end
		end)
		inst:ListenForEvent("unequipped", function(inst, data)
			local owner = data and data.owner
			if owner and owner.prefab == "wilson" then
				inst.components.perishable:StartPerishing()
			end
		end)
	end
end)

Replace "wilson" for your character.

9 minutes ago, DarkXero said:

AddPrefabPostInit("flowerhat", function(inst)
	if inst.components.perishable then
		inst:ListenForEvent("equipped", function(inst, data)
			local owner = data and data.owner
			if owner and owner.prefab == "wilson" then
				inst.components.perishable.updatetask:Cancel()
				inst.components.perishable.updatetask = nil
			end
		end)
		inst:ListenForEvent("unequipped", function(inst, data)
			local owner = data and data.owner
			if owner and owner.prefab == "wilson" then
				inst.components.perishable:StartPerishing()
			end
		end)
	end
end)

Replace "wilson" for your character.

thanks again

22 minutes ago, DarkXero said:

AddPrefabPostInit("flowerhat", function(inst)
	if inst.components.perishable then
		inst:ListenForEvent("equipped", function(inst, data)
			local owner = data and data.owner
			if owner and owner.prefab == "wilson" then
				inst.components.perishable.updatetask:Cancel()
				inst.components.perishable.updatetask = nil
			end
		end)
		inst:ListenForEvent("unequipped", function(inst, data)
			local owner = data and data.owner
			if owner and owner.prefab == "wilson" then
				inst.components.perishable:StartPerishing()
			end
		end)
	end
end)

Replace "wilson" for your character.

now it wont let me eat the nightmare fuel but it displays the option to eat it

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