Jump to content

[HELP] Perk: Ability to plant flowers from seeds


Recommended Posts

@Donnervogel, Yep, use AddPrefabPostInit on seeds to give them the deployable component:

inst:AddComponent("deployable")inst.components.deployable.ondeploy = OnDeploy

Then in OnDeploy, it's the exact same code as with butterflies:

local function OnDeploy(inst, pt)     local flower = SpawnPrefab("flower") -- spawns a flower    if flower then        flower:PushEvent("growfrombutterfly")        flower.Transform:SetPosition(pt:Get()) -- moves it to where you clicked        inst.components.stackable:Get():Remove() -- removes seeds from your inventory    endend

And to restrict it only to a specific character, you have to override the Deploy function of deployable to add your own verification:

local old_Deploy = inst.components.deployable.Deployinst.components.deployable.Deploy = function(self, pt, deployer)    if deployer:HasTag("seed_deployer") then        return old_Deploy(self, pt, deployer)    else        deployer.components.talker:Say("I can't do that.")    end    return falseend

You'll just have to add the seed_deployer tag (you can rename it) to your character.

You can even make the character say something if they can't plant a seed :p

Edited by Jjmarco
Link to comment
Share on other sites

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
 Share

×
  • Create New...