Donnervogel Posted February 21, 2015 Share Posted February 21, 2015 So since butterflies can be planted to create flowers, would it be possible to code it so that seeds can as well? And then would it be possible to restrict that ability to a specific character? Link to comment Share on other sites More sharing options...
Jjmarco Posted February 21, 2015 Share Posted February 21, 2015 (edited) @Donnervogel, Yep, use AddPrefabPostInit on seeds to give them the deployable component:inst:AddComponent("deployable")inst.components.deployable.ondeploy = OnDeployThen 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 endendAnd 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 falseendYou'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 Edited February 21, 2015 by Jjmarco Link to comment 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