How to obtain the actual GUID?

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
hanzawa1991
Posts: 73
Joined: Tue Apr 05, 2022 9:05 am

How to obtain the actual GUID?

Post by hanzawa1991 »

I would like to inquire about implementing a Lua script in a scenario where a blue faction aircraft (e.g., E-2D) detects a red faction target (e.g., HIMARS rocket) and then guides a blue faction suicide drone to attack the HIMARS (to be placed in a special action). I am facing two challenges in Lua programming: 1) How to obtain the actual GUID of the enemy's HIMARS from the perspective of the blue faction, so I can use commands like ScenEdit_KillUnit({guid = unit.guid}); 2) How to write a script for the drone to rapidly fly towards the target. :(
User avatar
KLAB
Posts: 500
Joined: Tue Feb 27, 2007 5:24 pm

Re: How to obtain the actual GUID?

Post by KLAB »

Select the unit, in editor scroll down into the unit options or and amongst those menus there is copy GUID or from memory press Ctrl X and it should have copied the GUID for you to then paste wherever Text file etc.

I will check when I am near a machine but from memory getting GUID is straightforward.
K
User avatar
blu3s
Posts: 1122
Joined: Fri Jul 08, 2022 9:45 am

Re: How to obtain the actual GUID?

Post by blu3s »

You can obtain the guid for attacking a contact from its Contact Wrapper

Note that for AttackContact function you must use the Contact GUID and not the Unit GUID.

You can create an event with a trigger on UnitDetected, use the filters on TargetFilter to only triggers the HIMARS detection, and then with ScenEdit_UnitC() that gives you the contact wrapper of the unit that fires the event, use ScenEdit_AttackContact() or create a mission to attack the contact using your drones. More info about creating triggers and events here: https://commandlua.github.io/index2.html#EventHandling


Attached a Lua example, the first part it's the setup of the scenario, and the second part it's the logic for the Event Creation and a the function to attack the contact. Create a new scenario, open the lua console and copy paste the script.
Attachments
Firing on Specific Unit Detection.zip
(1.05 KiB) Downloaded 40 times
Post Reply

Return to “Lua Legion”