FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login
    The current pre-release of the client ("pioneer" in the version) is only compatible to itself. So you can only play with other testers. Please be aware!

    Problem destroying an entity I've created

    Scheduled Pinned Locked Moved Modding & Tools
    4 Posts 2 Posters 204 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      Resin_Smoker
      last edited by

      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()
      end
      

      The "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

      Kykhu Oss https://youtu.be/JUgyGTgeZb8
      Unit Thrower https://youtu.be/iV8YBXVxxeI
      Beam Tentacle https://youtu.be/le5SNwHvC4c
      Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
      Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

      R 1 Reply Last reply Reply Quote 0
      • R Offline
        Resin_Smoker @Resin_Smoker
        last edited by

        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,
        

        Kykhu Oss https://youtu.be/JUgyGTgeZb8
        Unit Thrower https://youtu.be/iV8YBXVxxeI
        Beam Tentacle https://youtu.be/le5SNwHvC4c
        Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
        Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

        1 Reply Last reply Reply Quote 0
        • JipJ Offline
          Jip
          last edited by

          You forgot to do self.CloakEntity = ent in your original script 🙂

          A work of art is never finished, merely abandoned

          R 1 Reply Last reply Reply Quote 0
          • R Offline
            Resin_Smoker @Jip
            last edited by

            @jip Originally i was using...

            self.CloakEntity = self:ForkThread(CreateCloakedEntity)

            Uploaded V8 and it will include this unit... URA0206 Cybran Vampire

            Kykhu Oss https://youtu.be/JUgyGTgeZb8
            Unit Thrower https://youtu.be/iV8YBXVxxeI
            Beam Tentacle https://youtu.be/le5SNwHvC4c
            Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
            Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

            1 Reply Last reply Reply Quote 0
            • First post
              Last post