Jump to content

Recommended Posts

Posted

Can someone help me with a couple of lines of LUA code? I had hoped that a solution to this seemingly simple problem would avail itself but alas to no avail over the course of this project. Now at the end I still have no working solution for:

 

1. Spawn late activate object (REDTANK).

2. Check if object exists in an 'if then".

3. Despawn object only to be possibly respawned later.

 

I need help with some lua scripting to achieve above. I already have 1 in the form of:

Spawn_Vehicle_1 = SPAWN:New( "REDTANK" )
Spawn_Group_1 = Spawn_Vehicle_1:Spawn()

but it seems like there should be an easier line of code to do this.

I don't have 2 at all and I have 3 but I can't get it to work. I've tried various iterations of the below.

local dest = GROUP:FindByName("REDTANK"):destroy()
local myObj = GROUP:FindByName("REDTANK")
myObj:destroy()

 

To be clear on my objectives I want this to be a "switch" that can be turned on and off and is spawned out of the way and does not need to be seen by players. It will be saved by a persistent save script for campaign restarts.

Posted

1. figured out.

local redtank = Group.getByName( 'REDTANK' )
Group.getByName('REDTANK'):activate()

 

3. figured out.

Group.getByName('REDTANK'):destroy()

 

2. ??? elusive.

local redtank = Group.getByName( 'REDTANK' )
Group.getByName('REDTANK'):activate()
--Group.getByName('REDTANK'):destroy()
--if Group.getByName('REDTANK'):isActive() == true then
if Group.getByName('REDTANK'):isExist() == true then
trigger.action.outText("YES REDTANK", 420)
else
trigger.action.outText("NO REDTANK", 420)
end

 

If I use isExist I always get YES REDTANK no matter if I destroy() or not.

If I use isActive I get group is nil no matter if I destroy() or not.

 

 

 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...