dave9664 Posted March 12, 2015 Share Posted March 12, 2015 Is there a way to stop the player from gaining sanity from picking up flowers? The only way my character is supposed to regain sanity is by killing, so I've made him an insomniac but the flowers are a problem. Also, I have no idea on how to stop losing sanity from eating raw meat, as he should be allowed to eat raw meat without a problem, is there a way to do this too? Thanks, and sorry for the noobness. Link to comment Share on other sites More sharing options...
DarkXero Posted March 12, 2015 Share Posted March 12, 2015 There are many ways to do that.Editing values, overriding functions, or making a reverse function occur to counteract another. For the flower:AddPrefabPostInit("flower", function(inst) local old = inst.components.pickable.onpickedfn inst.components.pickable.onpickedfn = function(inst, picker) if picker.prefab == "MyCharacter" then inst:Remove() else old(inst, picker) end endend)For meat:AddComponentPostInit("edible", function(self) local old = self.GetSanity function self:GetSanity(eater) if eater.prefab == "MyCharacter" and self.inst == "meat" then if self.inst.components.perishable and not self.inst.components.perishable:IsStale() and not self.inst.components.perishable:IsSpoiled() then self.ignoremeat = 0 end end return self.ignoremeat or old(self, eater) endend) Link to comment Share on other sites More sharing options...
SamWinchester Posted March 12, 2015 Share Posted March 12, 2015 Isnt there a code or something that gives the properties to the flower to gain this? Maybe they could provide it and you could simply make a mod to go along with your character to remove this gain. Link to comment Share on other sites More sharing options...
DarkXero Posted March 12, 2015 Share Posted March 12, 2015 local function onpickedfn(inst, picker) if picker and picker.components.sanity then picker.components.sanity:DoDelta(TUNING.SANITY_TINY) end inst:Remove()endinst:AddComponent("pickable")inst.components.pickable.onpickedfn = onpickedfnThis is the code in the flower prefab that gives you sanity. If you want to strictly attach code to the master_postinit of your character, you can do it like:local function master_postinit(inst) inst:ListenForEvent("picksomething", function(inst, data) if data and data.object.prefab == "flower" and inst.components.sanity then inst.components.sanity:DoDelta(-TUNING.SANITY_TINY) end endend Link to comment Share on other sites More sharing options...
dave9664 Posted March 12, 2015 Author Share Posted March 12, 2015 That's great thank you Link to comment 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