Naidingo Posted February 8, 2015 Share Posted February 8, 2015 I am trying to make my character have negative affects from eating fruits/veggies and be able to eat monster meat just like regular meat. This is the coding I have written for it at the moment, but it does not work. It doesn't crash the game but none of the affects I tried to write are going off and not sure what the problem is. Is anyone able to help point out what I did wrong? Link to comment Share on other sites More sharing options...
Blueberrys Posted February 9, 2015 Share Posted February 9, 2015 @Naidingo Where are you calling this function? Link to comment Share on other sites More sharing options...
Naidingo Posted February 9, 2015 Author Share Posted February 9, 2015 in the scripts\prefabs\ LUA file Link to comment Share on other sites More sharing options...
Blueberrys Posted February 9, 2015 Share Posted February 9, 2015 @Naidingo Defining a local function won't do anything. You need to override whichever function you're trying to change.I recommend you read more on lua scope, and see the Eater component ("..\scripts\components\eater.lua") to find which function you want to override. Link to comment Share on other sites More sharing options...
Naidingo Posted February 9, 2015 Author Share Posted February 9, 2015 Awe man. Well thank you for the help : ) Link to comment Share on other sites More sharing options...
Blueberrys Posted February 9, 2015 Share Posted February 9, 2015 @Naidingo, welcome! Here's a bit of code to get you started.inst.components.eater.old_Eat = inst.components.eater.Eatinst.components.eater.Eat = function(self, food) -- Do your stuff here inst.components.eater:old_Eat(food)endRead the "Tables as objects (and how to modify their functions nicely)" section of this guide for more information. Link to comment Share on other sites More sharing options...
Naidingo Posted February 11, 2015 Author Share Posted February 11, 2015 Hey @Blueberrys ! Thank you so much! I had to reword the code you linked a little bit to get it to work but I finally got it working after messing with it for a few days lol. Thank you for the links and all the help! : ) 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.