Page 1 of 1

Event Question

Posted: Tue Jul 09, 2019 11:41 pm
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?

RE: Event Question

Posted: Wed Jul 10, 2019 12:16 am
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.