HatefulGravey Posted March 8, 2016 Share Posted March 8, 2016 (edited) In another thread I was asking about giving a character the ability to eat things that were not edible. The reason for this is a character that will eat tools. I have the code for his ability to eat them working (well enough, there were some unintended side effects I can go into later if need be), and each tool has different hunger/sanity/health effects. Now to move on to the next issue. I want to be able to trigger special effects when tools are eaten. My original plan was to create a new food type and put all the tools in it. The more I think about this though the more I'm certain I haven't seen an example of a mod editing a component, normally just prefabs. So, does anyone know of a way to do this? The other option is just to make all tools part of another food type the character can eat and compare what was eaten to a list of items that trigger the effects. To do this I need to be able to call the item I just ate to compare to the list. Is there are command that will call the name of the item the character just ate? Edited March 8, 2016 by HatefulGravey Link to comment https://forums.kleientertainment.com/forums/topic/65225-creating-a-new-food-type/ Share on other sites More sharing options...
Arkathorn Posted March 8, 2016 Share Posted March 8, 2016 Try 'inst.components.eater:SetOnEatFn(oneatfn)'. The function takes the player as it's first argument, and the eaten item as it's second. For example: --In your character's 'fn' function: inst.components.eater:SetOnEatFn(function(eater, food) if food.prefab == "pickaxe" or food.prefab == "goldenpickaxe" then print("Player ate a pickaxe!") end if food.prefab == "shovel" or food.prefab == "goldenshovel" then print("Player ate a shovel!") end if food.prefab == "axe" or food.prefab == "goldenaxe" then print("Player ate an axe!") end end) Link to comment https://forums.kleientertainment.com/forums/topic/65225-creating-a-new-food-type/#findComment-731165 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