dnjswns951 Posted December 21, 2014 Share Posted December 21, 2014 I tried that when the character eats evil petals, health goes up by 1. and here is my code.... in my modmain.lua file local function oneatingpetals_evilevilpostinit(inst) inst:AddComponent("edible") inst.components.edible.healthvalue = 1 inst.components.edible.hungervalue = 0 inst.components.edible.foodtype = "VEGGIE" end AddPrefabPostInit("petals_evil", oneatingpetals_evilevilpostinit) it works fine. But in the game, when I open the console screen, it says "components "edible" already exists!" So I am just wondering if this code is OK or is there better way to achieve it. The other way I tried is that I copied the whole petals_evil.lua file and changed code in that file. And put that file in my mod(scrips/prefab) folder, and it also worked fine. So which one is better way to to this? Or is there a even better way? Link to comment https://forums.kleientertainment.com/forums/topic/47238-some-more-questions-about-addprefabpostinit-function/ Share on other sites More sharing options...
Mobbstar Posted December 21, 2014 Share Posted December 21, 2014 (edited) That means literally just that: petals are edible per default, yet you attempt to add the edible component again. You can't make them ediblier EDIT: As you said, there's no issue in leaving that line there, but it spams the log.txt a bit... Edited December 21, 2014 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/47238-some-more-questions-about-addprefabpostinit-function/#findComment-590830 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