Page 1 of 1

Setting Submarine Depth

Posted: Mon Apr 05, 2021 9:29 am
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

RE: Setting Submarine Depth

Posted: Mon Apr 05, 2021 10:00 am
by ultradave
Should "alt" be a negative number?

Dave

RE: Setting Submarine Depth

Posted: Mon Apr 05, 2021 2:08 pm
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.


RE: Setting Submarine Depth

Posted: Mon Apr 05, 2021 2:15 pm
by KnightHawk75
altitude and negative, or Depth= {positive}

RE: Setting Submarine Depth

Posted: Mon Apr 05, 2021 5:51 pm
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."


RE: Setting Submarine Depth

Posted: Wed Apr 07, 2021 4:42 am
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

RE: Setting Submarine Depth

Posted: Wed Apr 07, 2021 6:27 pm
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)