LUA to change submarine depth

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
AdmiralSteve
Posts: 288
Joined: Mon Mar 28, 2011 2:32 pm
Location: Red Bluff, CA

LUA to change submarine depth

Post by AdmiralSteve »

I have this small script that changes the depth of a submarine as it changes missions from patrol to land attack;

ScenEdit_SetSidePosture('USN Submarine', 'PLAN PLAAF', 'H')
ScenEdit_SetMission('USN Submarine','USS John Warner SSN785 Patrol',{stationDepthSubmarine=-30})
ScenEdit_AssignUnitToMission('USS John Warner SSN785', 'Palawan Strike')

What I can't figure out is after the submarine is assigned to 'Palawan Strike', it settles back down below launch depth and the TLAM's cannot launch. Any suggestions? Scenario is attached.

Thank you,

Steve


Attachments
TroubledScenarios.zip
(177.73 KiB) Downloaded 16 times
“There are no extraordinary men...just extraordinary circumstances that ordinary men are forced to deal with.”
Admiral William Frederick Halsey Jr. 1882-1959

Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: LUA to change submarine depth

Post by Whicker »

in your line 2 you are setting station depth but on a strike mission there is no station depth. It is just inheriting the depth from the patrol missions station depth so you need to change it.

I did:

ScenEdit_SetSidePosture('USN Submarine', 'PLAN PLAAF', 'H')

ScenEdit_AssignUnitToMission('USS John Warner SSN785', 'Palawan Strike')

ScenEdit_SetUnit({name='USS John Warner SSN785', guid='924f266e-24e2-436c-b473-5d504ea796c2', depth= '130 FT', moveto=true})

moveto means that the altitude change doesn't happen instantly - it moves to it as it should. First time I have seen that. Once the mission is over you probably need to do something to put it back on the patrol mission? just thinking it will stay at shallow depth and maybe that will be bad for it.
User avatar
AdmiralSteve
Posts: 288
Joined: Mon Mar 28, 2011 2:32 pm
Location: Red Bluff, CA

RE: LUA to change submarine depth

Post by AdmiralSteve »

ORIGINAL: Whicker



moveto means that the altitude change doesn't happen instantly - it moves to it as it should. First time I have seen that. Once the mission is over you probably need to do something to put it back on the patrol mission? just thinking it will stay at shallow depth and maybe that will be bad for it.

Thank you very much. I will put this in. And yes, the sub will go back to a patrol mission but I had to get past this step.

Steve
“There are no extraordinary men...just extraordinary circumstances that ordinary men are forced to deal with.”
Admiral William Frederick Halsey Jr. 1882-1959

Post Reply

Return to “Lua Legion”