Lua Question Regarding the Operations Planner

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
artao5
Posts: 124
Joined: Fri Feb 24, 2023 7:24 am

Lua Question Regarding the Operations Planner

Post by artao5 »

So I can see the power in using Lua to set missions as satisfied or to trigger them in the Operations Planner. Buuuut .. I've never used Lua before. I've attempted programming numerous times tho, so I should be able to pick it up fairly quick from what I've read. CMO-specific stuff I'll need to reference. Most of my programming was TI Extended BASIC, but I've fiddled a little bit successfully with Python; but only simple stuff. Other languages I've not had much success with tho. (Aside from Inform 6 and Inform 7. But that's different.)
I'm trying to do the Strike Planner Tutorial "Pealing [sic] the Onion" using missions, the operations planner, phases, and triggers involving Lua.
I am trying to use Lua to determine if two targets have been destroyed. I have based it upon the "Unit(s) destroyed" template included in the operations planner's script editor. I've been trying to extrapolate it from one unit being destroyed to BOTH units needing to be destroyed before the mission is marked as satisfied.
However, the mission immediately gets marked as satisfied before it even takes off. If I manually set the mission to "Waiting for Trigger" it set's it back to "Satisfied" after a short while.
If it matters, the mission also has a Trigger To Start Mission of H-hour plus 5 minutes.
Here is the script I have hacked together. What have I done wrong?
(Mission save attached if interested or needed)

Code: Select all

--TEXT BETWEEN # SHOULD BE REPLACED WITH PROPER VALUES 
local Unit = ScenEdit_GetUnit({ guid= '5bb05762-0c60-4fe6-be8c-5a31dd2b137d'})
local Unit2 = ScenEdit_GetUnit({ guid= 'f09627b2-7da3-4662-bd8d-e0d9d932eaf0'})
-- or use :  local Unit = ScenEdit_GetUnit({ side='#UNIT'S SIDE#', unitname='#UNIT'S NAME#'})
return ((Unit == nil or Unit.IsDestroyed) and (Unit2 == nil or Unit2.IsDestroyed))
Attachments
Strike Tutorial #5 - Pealing the Onion Executing H - 10.zip
(157.57 KiB) Downloaded 3 times
Post Reply

Return to “Lua Legion”