Jump to content

Object finding it's own name (LUA)


Swany

Recommended Posts

So, I'm using a MOOSE script to spawn some objects over and over when they are destroyed. What I'm trying to do is

Create a tank

Have the tank move through set waypoints

When it reaches the last waypoint, destroy itself

 

So far, I have the objects creating and moving. The problem is I don't know how to find the unit's group name - When MOOSE spawns an object, it appends a #001, or #002, etc etc as each new object is created. Using the standard FindByName doesn't work because you wont know the name, it could be Tank #001, or Tank #099.

 

Isn't there some way, lets say using the Advanced Waypoint feature and Run Script, that you can tell it to look at itself and find out what its Group name is, so you can use the Destroy() function?

B. "Swany" Swanberg

Gigabyte Designare, Intel i9 9900KF (3.6, OC'd to 5.0)

32GB Patriot Viper Steel (black, non-RGB)

OS installed on a Samsung Evo 970 1TB SSD

DCS installed on a Samsun Evo 860 1TB SSD

EVGA 2080Ti 11GB

EVGA Supernova 720p 750w PS

3 Dell S2716DG monitors in Surround mode (7680x1440)

Oculus Rift S VR

Thrustmaster Warthog Throttle and Stick

Thrusmaster Rudder Pedals

assorted button boxes/Arduino boards

All drivers always kept up to date (30 days old, max)

Link to comment
Share on other sites

Yes and without harming any moose.

 

So whenever you have a do script or do script file associated with a waypoint task, there is a special definition for "self" of that group. The code would need to look like:

 

local gp = ...
gp:destroy()

 

A slightly confusing aspect of that is that one would assume that '...' means "ectetra or 'groupNameHere', but it doesn't. It is literally three periods that refer to self. Keep in mind this only works with do script and do script file tasks associated with groups. Outside of that it simply won't work.

  • Like 1

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Gimes, I could kiss you! Is there anything similar that can be used outside of the Run Script and Script File? I've had other thins I've tried to get to work and have run into the same issue. That #001 always jams me up (and in these cases the waypoint option isn't an option). In MOOSE I've tried using SETs with no luck - Most likely due to me very VERY limited understanding of LUA and coding. I wouldn't even call me a novice and NOOB would be generous. More like flailing around in the dark and seeing what sticks

B. "Swany" Swanberg

Gigabyte Designare, Intel i9 9900KF (3.6, OC'd to 5.0)

32GB Patriot Viper Steel (black, non-RGB)

OS installed on a Samsung Evo 970 1TB SSD

DCS installed on a Samsun Evo 860 1TB SSD

EVGA 2080Ti 11GB

EVGA Supernova 720p 750w PS

3 Dell S2716DG monitors in Surround mode (7680x1440)

Oculus Rift S VR

Thrustmaster Warthog Throttle and Stick

Thrusmaster Rudder Pedals

assorted button boxes/Arduino boards

All drivers always kept up to date (30 days old, max)

Link to comment
Share on other sites

You can use the OnSpawnGroup callback function to get the spawned group and its name: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Spawn.html##(SPAWN).OnSpawnGroup

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

  • Recently Browsing   0 members

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