Fuffles Posted October 22, 2017 Share Posted October 22, 2017 (edited) Hello dearies, Im currently trying to make a new structure that works very similar to the bee box, with one tad difference, it gives 1 additional item on the last stage so it would give you 6 of X and 1 of Y and now Im thinking how to acctually do that Quote local levels = { { amount=6, idle="honey3", hit="hit_honey3" }, { amount=3, idle="honey2", hit="hit_honey2" }, { amount=1, idle="honey1", hit="hit_honey1" }, { amount=0, idle="bees_loop", hit="hit_idle" }, } -blah blah blah- inst.components.harvestable:SetUp("honey", 6, nil, onharvest, updatelevel) any help? Edited October 22, 2017 by DragonflyTheGiant last stage Link to comment https://forums.kleientertainment.com/forums/topic/83189-creating-a-2-item-creating-structure/ Share on other sites More sharing options...
w00tyd00d Posted October 22, 2017 Share Posted October 22, 2017 (edited) @DragonflyTheGiant Gotchu fam Spoiler Just paste either one of these in to your modmain: -- For just a single item of the secondary product function HarvestableCompPostInit(comp) local old_Harvest = comp.Harvest comp.Harvest = function(self, picker) if self.inst.prefab == "<your structure>" and self.produce >= <# of produce needed> then local loot = GLOBAL.SpawnPrefab("<your extra item>") picker.components.inventory:GiveItem(loot) end return old_Harvest(self, picker) -- must be returned for the actionfail callback end end AddComponentPostInit("harvestable", HarvestableCompPostInit) -- For multiples of the secondary product function HarvestableCompPostInit(comp) local old_Harvest = comp.Harvest comp.Harvest = function(self, picker) if self.inst.prefab == "<your structure>" and self.produce >= <# of produce needed> then local loot = GLOBAL.SpawnPrefab("<your extra item>") for i = 1, <num or variable of how many you want spawned> do picker.components.inventory:GiveItem(loot) end end return old_Harvest(self, picker) -- must be returned for the actionfail callback end end AddComponentPostInit("harvestable", HarvestableCompPostInit) Hope this helps! Edited October 22, 2017 by w00tyd00d Link to comment https://forums.kleientertainment.com/forums/topic/83189-creating-a-2-item-creating-structure/#findComment-965612 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