Problem destroying an entity I've created
-
As the title suggests, my entity...
CreateCloakEntity = function(self) if myDebug then WARN('CreateCloakEntity') end ent = import('/lua/sim/Entity.lua').Entity({Owner = self,}) ent:AttachBoneTo( -1, self, 'ura0206' ) ent:SetMesh(self.MeshCloak) ent:SetDrawScale(self.MeshScale) ent:SetVizToFocusPlayer('Always') ent:SetVizToAllies('Always') ent:SetVizToNeutrals('Never') ent:SetVizToEnemies('Never') self.Trash:Add(ent) end,Is created and attaches to the parent unit just fine. However later on when I need to dismiss the entity, I'm having problems removing it.
for k, v in self.CloakEntity do v:Destroy() endThe "self.CloakEntity" is the Global table used to save the entity within the parent unit. Yet Destroy() neither flags an error nor removes the entity.
Any ideas or suggestions would be much apricated.
Side note: Looking inside of /lua/sim/Entity.lua I see that It's with a few basic functions that are mostly undefined / blank. Is it possible that's why the entity is not destroyed?
Resin
-
Got it !
SetCloak = function(self, set) if myDebug then WARN('SetCloak: ', set) end local bp = self:GetBlueprint() if set and self.DoneBeingBuilt then if myDebug then WARN(' Delay before going active') end WaitTicks(self.CloakDelay or 1) if not self:IsDead()then if myDebug then WARN(' Cloak active') end self:HideBone('ura0206', false) if not self.CloakEntity then self:CreateCloakEntity() end self:EnableIntel('Cloak') self:EnableIntel('RadarStealth') self.CloakActive = true end else if myDebug then WARN(' Dropping cloak') end if self.CloakEntity then self.CloakEntity:Destroy() self.CloakEntity = nil end self:ShowBone('ura0206', false) self:DisableIntel('Cloak') self:DisableIntel('RadarStealth') self.CloakActive = false end end, CreateCloakEntity = function(self) if myDebug then WARN('CreateCloakEntity') end ent = import('/lua/sim/Entity.lua').Entity({Owner = self,}) ent:AttachBoneTo( -1, self, 'ura0206' ) ent:SetMesh(self.MeshCloak) ent:SetDrawScale(self.MeshScale) ent:SetVizToFocusPlayer('Always') ent:SetVizToAllies('Always') ent:SetVizToNeutrals('Never') ent:SetVizToEnemies('Never') self.CloakEntity = ent self.Trash:Add(ent) end, -
You forgot to do
self.CloakEntity = entin your original script
-
@jip Originally i was using...
self.CloakEntity = self:ForkThread(CreateCloakedEntity)
Uploaded V8 and it will include this unit... URA0206 Cybran Vampire
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login