Jump to content

Recommended Posts

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?

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 :razz:

 

EDIT: As you said, there's no issue in leaving that line there, but it spams the log.txt a bit...

Edited by Mobbstar

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...