Mertaan Posted March 4, 2015 Share Posted March 4, 2015 I'm looking for something like this pseudoscript: if act.target.prefab == was-placed-on-the-ground-by-this-person then -do somethingelse -do something else.end Any ideas? Link to comment Share on other sites More sharing options...
rezecib Posted March 4, 2015 Share Posted March 4, 2015 @Mertaan, This is not something the game keeps track of on its own, so it won't be that straightforward to implement. I'm guessing you're trying to write an ownership system for placed structures? Link to comment Share on other sites More sharing options...
Mertaan Posted March 4, 2015 Author Share Posted March 4, 2015 Yeah. The mod wallgates has builder-only locks so i thought it might already be in the game with something like the UserID tag. Link to comment Share on other sites More sharing options...
DarkXero Posted March 4, 2015 Share Posted March 4, 2015 Well, on the builder component, inside the DoBuild function, you have:self.onBuild(self.inst, prod)prod.OnBuilt(prod, self.inst)For both items and structures, that you can define and use.local function onBuild(inst, prod) if prod.prefab == "ThisThing" and inst.prefab == "ThisCharacter" then -do something else -do something else endendAddPlayerPostInit(function(inst) inst.components.builder.onBuild = onBuildend Link to comment Share on other sites More sharing options...
Mertaan Posted March 5, 2015 Author Share Posted March 5, 2015 (edited) Well, on the builder component, inside the DoBuild function, you have:self.onBuild(self.inst, prod)prod.OnBuilt(prod, self.inst)For both items and structures, that you can define and use.local function onBuild(inst, prod) if prod.prefab == "ThisThing" and inst.prefab == "ThisCharacter" then -do something else -do something else endendAddPlayerPostInit(function(inst) inst.components.builder.onBuild = onBuildend Thanks! I think this could work. On a related note:local Combatable = GetModConfigData("Combatable ")local function RemoveCombatable(inst, doer) -- maybe doer here? if inst and inst.components.combat and (Combatable == 1) then--error--->>>> if doer:HasTag("player") then inst:RemoveComponent('combat') end endendAny idea what the other:HasTag("player") then should be here? it works fine except for that bit. Its likely something simple but my brain is on standby mode and i can't figure it out.I've had something similar working before so i know it's almost right..I think it's like doer or actions maybe. context: I'm trying to make a placed item unattackable by players, but still attackable by monsters. Edited March 5, 2015 by Mertaan Link to comment Share on other sites More sharing options...
DarkXero Posted March 5, 2015 Share Posted March 5, 2015 Because there is no "other" variable.If you remove the combat component then nothing will destroy it unless it's workable. Instead of removing combat, you will have to edit something from combat or combat_replica, like:AddComponentPostInit("combat_replica", function(self) local old = self.CanBeAttacked function self:CanBeAttacked(attacker) if self.inst:HasTag("MyModTag") and attacker:HasTag("player") then return false end old(self, attacker) endend)But I take you don't want to make things not attackable, you want to make them non hammerable, yes? Link to comment Share on other sites More sharing options...
Mertaan Posted March 5, 2015 Author Share Posted March 5, 2015 (edited) No i actually do want them unattackable (by players only) It's already safe from hammers. Its just the check for tag thats not working.. :'( Edited March 5, 2015 by Mertaan 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