Jump to content

Stop releasing Bees from Bee Boxes if a certain Tag is there


Recommended Posts

@DragonflyTheGiant That's an easy one :) 

Spoiler

-- Plop this bad larry in your modmain.lua

function BeeboxPostInit(inst)
	local function setlevel(inst, level)
	    if not inst:HasTag("burnt") then
	        if inst.anims == nil then
	            inst.anims = { idle = level.idle, hit = level.hit }
	        else
	            inst.anims.idle = level.idle
	            inst.anims.hit = level.hit
	        end
	        inst.AnimState:PlayAnimation(inst.anims.idle)
	    end
	end

	local function updatelevel(inst)
	    if not inst:HasTag("burnt") then
	        for k, v in pairs(levels) do
	            if inst.components.harvestable.produce >= v.amount then
	                setlevel(inst, v)
	                break
	            end
	        end
	    end
	end

	local function new_onharvest(inst, picker)
	    if not inst:HasTag("burnt") then
	        updatelevel(inst)
			if inst.components.childspawner ~= nil and not (GLOBAL.TheWorld.state.iswinter or picker:HasTag("<your tag here>")) then	-- replace this with your tag
	            inst.components.childspawner:ReleaseAllChildren(picker)
	        end
	    end
	end

	if GLOBAL.TheWorld.ismastersim then
		inst.components.harvestable:SetUp("honey", 6, nil, new_onharvest, updatelevel)
	end
end

 

Hope this helps!

Edited by w00tyd00d
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...