Page 1 of 1

Event action on waypoints...

Posted: Wed Jul 08, 2026 4:30 pm
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?"

Re: Event action on waypoints...

Posted: Wed Jul 08, 2026 8:28 pm
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 745 times

Re: Event action on waypoints...

Posted: Thu Jul 09, 2026 2:16 pm
by thewood1
Thanks. I tried using Gemini and it got me the code. The piece I was missing was the action on the waypoint.

Re: Event action on waypoints...

Posted: Thu Jul 09, 2026 5:35 pm
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