Event action on waypoints...

Take command of air and naval assets from post-WW2 to the near future in tactical and operational scale, complete with historical and hypothetical scenarios and an integrated scenario editor.

Moderator: MOD_Command

Post Reply
thewood1
Posts: 10362
Joined: Sun Nov 27, 2005 6:24 pm
Location: Boston

Event action on waypoints...

Post by thewood1 »

https://forums.matrixgames.com/viewtopi ... 8#p5282118

Posted this in Lua Legion a few days ago with no response after 40 reads. So posting in the broader forum to get more exposure.

From the post:

"in 1825, we got this new feature:

ADDED: You can now assign an event action to a waypoint.
- The unit can be obtained by the usual ScenEdit_UnitX().
- The waypoint action is a dropdown of the event actions.
- The triggering unit and WP IDs are passed as a local Lua table 'wpAction'. The full details can be accessed thru the SE functions using the unit (wpAction.unit) and wp (wpAction.wp) GUIDs.

Is there an example of this being used anywhere?

Also, is there a plan to update the lua CMO reference doc?"
Nikel
Posts: 3233
Joined: Tue Mar 24, 2009 10:51 am

Re: Event action on waypoints...

Post by Nikel »

With the help of the AI, I just tested the error after error, this seems to work.



Code to create a lua script action.
ScenEdit_SetAction({
mode = 'add',
name = 'WP_TEST',
description = 'WP_TEST',
type = 'LuaScript',
scripttext = script,
scriptfor = 1
})


Code to print Unit GUID and WP GUID. Video example below.

local msg = "WP Action data:\n"

msg = msg .. "Unit GUID: " .. tostring(wpAction.unit) .. "\n"
msg = msg .. "WP GUID: " .. tostring(wpAction.wp)

local a = ScenEdit_MsgBox(msg, 0)



Code to create Action to end the scenario at WP. I tried with the type End scenario, but did not work, needs lua code.

ScenEdit_SetAction({
mode = "add",
type = "LuaScript",
name = "End Scenario at WP",
scriptfor = 1,
scripttext = "ScenEdit_EndScenario()"
})

WPL.gif
WPL.gif (1.12 MiB) Viewed 282 times
thewood1
Posts: 10362
Joined: Sun Nov 27, 2005 6:24 pm
Location: Boston

Re: Event action on waypoints...

Post by thewood1 »

Thanks. I tried using Gemini and it got me the code. The piece I was missing was the action on the waypoint.
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Re: Event action on waypoints...

Post by Parel803 »

FWIW
I was not aware and took me a while to find that I could change Script For setting in the Lua action.
With regards GJ
Attachments
ScriptFor.png
ScriptFor.png (40.76 KiB) Viewed 216 times
Post Reply

Return to “Command: Modern Operations series”