Jump to content

Recommended Posts

I made this mod, and with something I did (I don't really know what it was), it broke. The mod only works when a server launches, but stops doing anything after that.

local function LikeJazz(inst)
	
  	--Make sure inst has a talker component
	if not inst.components.talker then
		inst:AddComponent("talker")
	end
	
  	--Decide wether it should say something
	local num = math.random()
	local shouldsay = num >= GetModConfigData("frequency")
	
	if shouldsay and inst.components.talker then
		inst.components.talker:Say("Ya like jazz?")
	end
end

--Bees should say "Ya like jazz?" randomly when their state changes
AddPrefabPostInit("bee", function(inst)
	inst:ListenForEvent("newstate", LikeJazz(inst))
end)

This is my modmain. If I set shouldsay to true it will still only work once. What's wrong in the code? I've been looking for quite a while now and and any help would be appreciated.

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
×
  • Create New...