Event Question

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
vettim89
Posts: 3744
Joined: Fri Jul 13, 2007 11:38 pm
Location: Toledo, Ohio

Event Question

Post by vettim89 »

Not really a Lua question here but this is about the best place I can guess to put this:

I am designing a scenario where a sub has to lay a minefield. I want to have an event trigger when the minefield is complete. I tried setting up a zone and then have an event triggered by "unit enters area" with the type "weapon" selected. Unfortunately the game does not seem to recognize the mines as weapons.

Can any one give me a hint on how to set this up?
"We have met the enemy and they are ours" - Commodore O.H. Perry
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: Event Question

Post by Whicker »

you might be able to dig into the unit wrapper to see if the sub has mines still?

the mines themselves seem to be invisible/uneditable/unreachable via lua.

If you print out the units mounts, if it has mines on it you should be able to drill down and see how many are left. I just did a quick example with a sub I added mines to and this shows how many are left after it has been laying some down:

local u = SE_GetUnit({name='PLA-971 Akula I Improved [Shchuka-B]', guid='9b79c57f-0095-47e3-b2e7-e2aecddece75'})
print(u.mounts[13].mount_weapons[1].wpn_current)

if you just print u.mounts you can then look in the list and see what number the record is for the mine magazine and change the 13 to whatever yours is and see if that works. Then once that is 0 the ship should be done laying mines.
Post Reply

Return to “Lua Legion”