Jump to content

Recommended Posts

So, what i'd like to know is, how can i have an item that can be edible, specifically to a character, AND, whenever he eats said item, for a effect to be applied E.g. add a tag to the character, activating a timer, and when said timer is up, said effect is removed

 

Edit -  Oh hey, 555 posts. yay, i guess.

Edited by Blazingice26
Link to comment
https://forums.kleientertainment.com/forums/topic/30248-effects-on-eating/
Share on other sites

maybe add something like

---------------------------------------------------------------

local function item_oneaten(inst, eater)GetPlayer():AddTag("fridge")endinst:AddComponent("edible")inst.components.edible.foodtype = "EFFECTGIVER"inst.components.edible:SetOnEatenFn(item_oneaten)

-----------------------------------------------------------------

Then add something from Wx's script that lets it eat that type of food?

Or maybe, just add

-----------------------------------------------------------------

inst:AddComponent("edible")inst.components.edible.foodtype = "EFFECTGIVERICE"inst.components.edible:SetOnEatenFn(item_oneaten)

----------------------------

to the item then add

----------------------------

local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == "EFFECTGIVERICE" thenGetPlayer():AddTag("fridge")

------------------------------

To the character?

Edited by Blazingice26

maybe add something like

---------------------------------------------------------------

local function item_oneaten(inst, eater)GetPlayer():AddTag("fridge")endinst:AddComponent("edible")inst.components.edible.foodtype = "EFFECTGIVER"inst.components.edible:SetOnEatenFn(item_oneaten)

-----------------------------------------------------------------

Then add something from Wx's script that lets it eat that type of food?

Or maybe, just add

-----------------------------------------------------------------

inst:AddComponent("edible")inst.components.edible.foodtype = "EFFECTGIVERICE"inst.components.edible:SetOnEatenFn(item_oneaten)

----------------------------

to the item then add

----------------------------

local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == "EFFECTGIVERICE" thenGetPlayer():AddTag("fridge")

------------------------------

To the character?

Uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...............................................................................................

So, im taking a shot in the dark with the first thing i wanted to do (in the OP) i've added this function, and so it occurs on eating a certain item

local function onfreeze(inst, data)GetPlayer():AddTag("fridge")inst.components.health:SetMaxHealth(125)inst.components.hunger:SetMax(250)inst.components.sanity:SetMax(150)inst.components.combat.damagemultiplier = 1.inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.0) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.0) local Temperature = Class(function(self, inst)self.inherentinsulation = -30 local Health = Class(function(self, inst)inst.components.health.fire_damage_scale = 5self.fire_damage_scale = 5end   end       end
Edited by Blazingice26

Also, how would one make a character have a certain max hunger, but start at a lower max hunger then that, e.g has 300 max hunger, starts at 150 hunger

If you mean he spawns at half his hunger, look in the Wolfgang codes, if you mean he has to upgrade his hunger, look in the WX codes.

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