Residays Posted June 15, 2017 Share Posted June 15, 2017 So my mod adds tags to prods when they are being built via a function. local function OnBuild_becomevalid(inst, prod) if prod.components.burnable or prod.components.container or prod.components.crop or prod.components.dryer or prod.components.harvestable or prod.components.machine or prod.components.wardrobe or prod.components.sleepingbag or prod.components.writeable or prod.components.deployable or prod.components.attunable then prod:AddTag("thisisvalid") (I know the if is quite long, sorry about that.) However, when the server is closed, the tag seems to be lost as nothing else that would have to do with it does what it's supossed to. local old_ACTION_HAMMER = GLOBAL.ACTIONS.HAMMER.fn GLOBAL.ACTIONS.HAMMER.fn = function(act) if act.target:HasTag("thisisvalid") then if HAMMERINGANNOUNCER == true then if LANGUAGE == "simplified_chinese" then GLOBAL.TheNet:Announce(act.doer:GetDisplayName()..has_been_hammered_by..act.target:GetDisplayName()..exclamation) print(act.doer:GetDisplayName()..has_been_hammered_by..act.target:GetDisplayName()..exclamation) end (Don't worry about the lack of ends, it's actually finished, I just put the important part.) If I don't close the server, then the text/announcement that I want to display does appear. So is there any way I can make the tag not be deleted/stay after closing the world? Thanks. Link to comment Share on other sites More sharing options...
alainmcd Posted June 15, 2017 Share Posted June 15, 2017 Maybe use an auxiliary component to save/load the state? local function oncaninteract(caninteract) if caninteract then self.inst:AddTag("CanInteract") else self.inst:RemoveTag("CanInteract") end end local CanInteract = Class(function(self, inst) self.inst = inst self.caninteract = false end, nil { caninteract = oncaninteract, }) function CanInteract:OnSave() return self.caninteract end function CanInteract:OnLoad(data) self.caninteract = data end return CanInteract 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