Jump to content

Announcing when somebody breaks, builds and/or lights a structure


Recommended Posts

Making my first mod, nothing happens at all when I try to light and/or hammer a structure. What am I doing wrong? How can I solve it?

Thanks in advance.

Spoiler

-- STRUCTURES
local function OnBuild_becomevalid(prod, inst)
	if prod.components.inventoryitem == nil or (prod.components.inventoryitem and prod.components.stackable == nil) then
		prod:AddTag("thisisvalid")
		GLOBAL.TheNet:Announce("A".. prod:GetDisplayName().. "has been built by " ..inst:GetDisplayName().."!")
	end
end

local old_ACTION_HAMMER = GLOBAL.ACTIONS.HAMMER.fn
GLOBAL.ACTIONS.HAMMER.fn = function(act)
if act.target:HasTag("thisisvalid") then 	
		GLOBAL.TheNet:Announce("A "..act.target:GetDisplayName().." has been hammered by "..act.doer:GetDisplayName().."!")
	end
	return old_ACTION_HAMMER(act)
end

local old_LIGHT_function = GLOBAL.ACTIONS.LIGHT.fn
GLOBAL.ACTIONS.LIGHT.fn = function(act)
if act.target:HasTag("thisisvalid") then 	
		GLOBAL.TheNet:Announce("A "..act.target:GetDisplayName().." has been lighted by "..act.doer:GetDisplayName().."!!")
	end
	return old_LIGHT_function(act)
end

 

 

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...