Setting Submarine Depth

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

Setting Submarine Depth

Post by butch4343 »

Folks,

I wonder if anyone can give me a step for a hint, I have a submarine assigned to and ASW patrol and the station depth set to -350ft what am looking to do is set up a script where the sub randomly changes depth every hour. I understand creating a random event script:

math.randomseed( os.time() )

a = math.random(1,10)

if a<5 then


The bit am struggling with is the setunit part. Ive tried to bodge together the script from the LUA Github page and came up with this:

ScenEdit_SetUnit({side="WP", unitname="K-511", alt =150})

Except it doesnt work, can ayone help me work out where Ive gone wrong?

Regards

Butch
User avatar
ultradave
Posts: 1640
Joined: Tue Aug 20, 2013 7:01 pm
Location: Rhode Island, USA

RE: Setting Submarine Depth

Post by ultradave »

Should "alt" be a negative number?

Dave
----------------
Dave A.
"When the Boogeyman goes to sleep he checks his closet for paratroopers"
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Setting Submarine Depth

Post by butch4343 »

Hi Dave

Thanks for the suggestion, I tried that mate but no joy, even if I could get them the to go either over the layer or under the layer or periscope depth ect.

KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Setting Submarine Depth

Post by KnightHawk75 »

altitude and negative, or Depth= {positive}
boogabooga
Posts: 988
Joined: Wed Jul 18, 2018 12:05 am

RE: Setting Submarine Depth

Post by boogabooga »

"altitude" and "speed" are read-only, I think, as these represent the actual altitude and speed of the unit at a particular instant. I think that the documentation needs to be fixed regarding this.

The variable that you want to set is called "manualAltitude."

The boogabooga doctrine for CMO: Any intentional human intervention needs to be able to completely and reliably over-ride anything that the AI is doing at any time.
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Setting Submarine Depth

Post by butch4343 »

Folks,

Aw your the greatest bunch, that worked like a charm [:)]

I was wondering whilst that works great for what am looking for I wondered if there's a way that you can set the depth to the preset depths in the throttle settings , so for example, you have a sub on patrol it periodically dips under the layer or over the layer or goes as deep as possible. Can that be set via LAU without having to work out the depth of the layer and entering that manually with the depth fingure ie "maunaldepth= -100 ect?

If not then its no matter.

Regards

Butch
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Setting Submarine Depth

Post by KnightHawk75 »

ORIGINAL: butch4343
I wondered if there's a way that you can set the depth to the preset depths in the throttle settings
Yes.
fb.asp?m=4588377 (post #6 and post #8 if doing aircraft)
Post Reply

Return to “Lua Legion”