Birdskull Posted March 26, 2020 Share Posted March 26, 2020 (edited) Hi. The idea here is for the character - Wort - to be able to "infect" trees by giving them spores, resulting in them being replaced by mushroom trees. Everything was going according to plan until the transformation itself. I've colored the problem lines red. They're copied from beequeenhive, and searching the forum brought me to an older thread suggesting the very same code for a similar goal. I've tried phrasing it so many ways and no dice. Hoping some fresh eyes might lend their wisdom. Thanks for reading. Ah, the dangers of working into the small hours of the morning. The code is fine. The problem is the prefab name for the red mushtree is "mushtree_medium", not "mushroom_tree_medium." I just didn't notice because the line telling me so was above the error message, and my sleep deprived self never looked up. local function TradeSporesPostInit(inst) if not inst.components.tradable then inst:AddComponent("tradable")end end AddPrefabPostInit("spore_medium", TradeSporesPostInit) local function FungalInfectionPostInit(inst) local function ShouldAcceptItem(inst, item, giver) return item.prefab == "spore_medium" and giver.prefab == "wort" end local function OnGetItem(inst, giver, item) if item ~= nil and item.prefab == "spore_medium" then item:Remove() SpawnPrefab("spat_splash_fx_full").Transform:SetPosition(inst:GetPosition():Get()) inst.SoundEmitter:PlaySound("dontstarve/creatures/spat/spit_hit") inst.SoundEmitter:PlaySound("dontstarve/cave/mushtree_tall_grow_2") local x, y, z = inst.Transform:GetWorldPosition() inst:Remove() local infection = SpawnPrefab("mushroom_tree_medium") infection.Transform:SetPosition(x, y, z) end end inst:AddComponent("trader") inst.components.trader:SetAcceptTest(ShouldAcceptItem) inst.components.trader.onaccept = OnGetItem end AddPrefabPostInit("evergreen", FungalInfectionPostInit) Edited March 26, 2020 by Birdskull Link to comment Share on other sites More sharing options...
krylincy Posted March 26, 2020 Share Posted March 26, 2020 Whats your error message? can you test with print/log if the function is called at all? 1 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