End Scenario Unit Enters Area

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
DavidRN
Posts: 91
Joined: Tue Jan 17, 2023 8:41 pm

End Scenario Unit Enters Area

Post by DavidRN »

Hi There

Doesn't appear to be working for me in test runs, is it the correct format?

ScenEdit_EndScenario('JMSDF', 'DSWMNJ-0HMNRI95PKFTO')
inArea=({'RP-214', 'RP-215', 'RP-216', 'RP-217'})

DB
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: End Scenario Unit Enters Area

Post by KnightHawk75 »

No, ScenEdit_EndScenario() takes no parameters.
I'm not sure what you're asking here, what are you trying to do\accomplish?


You would generally just define your in-area trigger in gui tools, and then for the action use built in end scenario in the list of actions (no lua required..), or if you have more you want to condition it upon ...you can use a 'condition' or a 'lua script' that that has similar logic and calls to ScenEdit_EndScenario().

For the later if say you are asking like in an area trigger for 1 thing if you want to check if something else is also in a certain area... like say we have objectA that triggers the event and is in Area A, and then you want to check if object b is inside some area (same or other), and end the scene if it is true but not end the scene if it's false.

Code: Select all

local objectB = SE_GetUnit({guid="some-guidhere"});  --get the object to check into a var.
if (objectB ~=nil) and objectB:inArea=({'RP-214', 'RP-215', 'RP-216', 'RP-217'}) then -- make sure it's not nil and check area
  print("debug: objectB is in the specified area, ending scene");
  ScenEdit_EndScenario();  --end scene
else
  print("debug: objectB is not in the specified area");
end
You could just make it a condition as well and use it that way, instead of invoking EndScene, you could just have the condition return true and false.

I attached a basic demo (build 1307+) showing both of the first 2 with requirement that 787 be in a certain area-B (pink\purple) in addition to a aircraft unit (b-52) triggering the check by entering area-A (yellow). Or .. Are you asking how to script the creation of an In Area trigger dynamically?
InAreaSample1307.zip
(10.23 KiB) Downloaded 5 times
Last edited by KnightHawk75 on Fri Jan 27, 2023 5:06 pm, edited 1 time in total.
DavidRN
Posts: 91
Joined: Tue Jan 17, 2023 8:41 pm

Re: End Scenario Unit Enters Area

Post by DavidRN »

KnightHawk75 wrote: Fri Jan 27, 2023 3:27 am No, ScenEdit_EndScenario() takes no parameters.
I'm not sure what you're asking here, what are you trying to do\accomplish?


You would generally just define your in-area trigger in gui tools, and then for the action use built in end scenario in the list of actions (no lua required..), or if you have more you want to condition it upon ...you can use a 'condition' or a 'lua script' that that has similar logic and calls to ScenEdit_EndScenario().

For the later if say you are asking like in an area trigger for 1 thing if you want to check if something else is also in a certain area... like say we have objectA that triggers the event and is in Area A, and then you want to check if object b is inside some area (same or other), and end the scene if it is true but not end the scene if it's false.

Code: Select all

local objectB = SE_GetUnit(guid="some-guidhere");  --get the object to check into a var.
if (objectB ~=nil) and objectB:inArea=({'RP-214', 'RP-215', 'RP-216', 'RP-217'}) then -- make sure it's not nil and check area
  print("debug: objectB is in the specified area, ending scene");
  ScenEdit_EndScenario();  --end scene
else
  print("debug: objectB is not in the specified area");
end
You could just make it a condition as well and use it that way, instead of invoking EndScene, you could just have the condition return true and false.

I attached a basic demo (build 1307+) showing both of the first 2 with requirement that 787 be in a certain area-B (pink\purple) in addition to a aircraft unit (b-52) triggering the check by entering area-A (yellow). Or .. Are you asking how to script the creation of an In Area trigger dynamically?

InAreaSample1307.zip

Hi

Thanks for the reply and the sample .....

Apologies yes I didnt make it very clear, a surface unit entering the RP area to end the scenario combined with a trigger.

DB
Post Reply

Return to “Lua Legion”