HugAProbe Posted January 27, 2015 Share Posted January 27, 2015 Hello, I'm new to modding and I wanted to create a character that looked like he had a big stomach but really his stomach is just the same as Wilson, just doubled. I doubled the max hunger to 300 and doubled the rate of hunger so that it depletes in the same amount of time. However, I don't know how to double the food's value so that my hunger goes down faster than I can gather food.How do I double the hunger I would normally get back from eating food?I saw a multiplier in the edible.lua that thought I could use in the character.lua , but I don't know how to change the local multiplier. I saw one thread that changed the multiplier but creating a new function but, I'm not sure how they did that.I'm currently using these in the character.lua inst.components.hunger:SetMax(TUNING.WILSON_HUNGER * 2) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 2)Thank you in advance for your help! Link to comment Share on other sites More sharing options...
Blueberrys Posted January 27, 2015 Share Posted January 27, 2015 @HugAProbe, this should do it.local function edible_postinit(self, inst) if inst.prefab == "your_character_prefab" then self.old_GetHunger = self.GetHunger self.GetHunger = function(self, eater) local multiplier = 2 return self:old_GetHunger(eater) * multiplier end endendAddComponentPostInit("edible", edible_postinit)Remember to change your_character_prefab accordingly. Edit: Fixed some mistakes above. Link to comment Share on other sites More sharing options...
debugman18 Posted January 27, 2015 Share Posted January 27, 2015 Alternatively, you could do something like this in your player prefab:inst.components.eater:SetOnEatFn(function(inst, food) local hunger = food.components.edible.hungervalue inst.components.hunger:DoDelta(hunger)end) Link to comment Share on other sites More sharing options...
HugAProbe Posted January 27, 2015 Author Share Posted January 27, 2015 @Blueberrys @debugman18 Thank you so much. I got them to work!Also debugman18, I understand how Blueberrys' code works but I'm really confused by how yours works. Could you please explain it? Link to comment Share on other sites More sharing options...
debugman18 Posted January 27, 2015 Share Posted January 27, 2015 @Blueberrys @debugman18 Thank you so much. I got them to work!Also debugman18, I understand how Blueberrys' code works but I'm really confused by how yours works. Could you please explain it? My code works by running a callback when the character eats. What happens is it gets the hunger value of the food being eaten, and it increases your hunger by that amount, on top of the hunger gained by eating the food. So basically, it doubles the hunger gain. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.