Page 1 of 1

No ship with ID?

Posted: Fri May 08, 2020 9:57 am
by Gunner98
Working on a very basic script which shouldn't be an issue but it is:

ScenEdit_AddUnit({type ='Submarine', name ='K-209', dbid =353, side ='WP', Base ='Murmansk', Heading = '300', Throttle = 'cruise', Depth = '300', latitude='70.1941604614258', longitude='34.5331382751465'})

One error and a couple questions:

Error: No ship with ID: 353. But I am calling for a submarine so I think that is the problem (see clip) (I've tried Submarine, submarine, Sub & sub)

Question 1: To assign the base I first tried the GUID but it was giving me errors so I put the base name in which should work. Is there a trick to adding a GUID to this bit?

Question 2: Instead of saying Throttle = 'cruise', Depth = '300', are there values for speed and depth settings? I remember seeing that somewhere but cannot recall for sure.

Thanks for you help.

B

Image

RE: No ship with ID?

Posted: Fri May 08, 2020 11:29 am
by TitaniumTrout
So I can place a sub with DBID 353 at the lat-lon you requested if I remove base='Murmansk'. I can place a sub with base='Murmansk' with a different DBID (in this case I used DBID 4). However it appears that the lat-lon is redundant as it places the unit at the base and not at the requested lat-lon.

What I did to get around the issue is :

local xx = ScenEdit_AddUnit({type ='Submarine', name ='K-209', dbid =353, side ='WP', Heading = '300', Throttle = 'cruise', Depth = '300', latitude='70.1941604614258', longitude='34.5331382751465'})
xx.base='Murmansk'

Image

Throttle = 0 gives you STOP, 1 is Creep, 2 is Cruise, 3 is Full, 4 is flank. I'm not sure about depth, setting the value to an integer just gives you depth in meters.

RE: No ship with ID?

Posted: Fri May 08, 2020 12:45 pm
by Gunner98
Thanks TT - works like a charm

B

RE: No ship with ID?

Posted: Fri May 08, 2020 1:58 pm
by KnightHawk75
Yes if you're adding a unit to a base during AddUnit the lat and lon don't matter, though it is actually created there momentarily before being moved into the base.
Keep in mind:
When using Base= during AddUnit() Base = XYZ means Insert this unit into base XYZ. Yes you must use a name and not a guid, I think that is doc error or a bug when it comes to feeding it a guid.
When using unitwrapper.base = XYZ it means Assign this unit's base as XYZ.
If you want to move a unit from somewhere after creation into a base you use HostUnitToParent() (and you can use guids or names in the parameters table, I can't recall ever not using guids)

BTW if you want depth in feet just do "-300 FT", it should work. Depth presets are 1-6 positive for a sub (6=surface,1-5 go from periscope=1,shallow=2,overlayer=3,underlayer=4,maxdepth=5) 3,4,5 are auto calculated based on location spawned during AddUnit() calls.

When using SetUnit() and also using manualAltitude= though you can use a direct value of 0 or less, or keywords of Over,Max,Periscope,Shallow,OverLayer,UnderLayer,MaxDepth,Surface. Keep in mind the later, keywords, when it comes to subs may not work right unless using build 1143.1 or higher per https://www.matrixgames.com/forums/tm.asp?m=4798808.




RE: No ship with ID?

Posted: Mon May 11, 2020 3:11 am
by michaelm75au
If adding an unit, and you include 'Base', I believe that it is trying to add the unit to the base (i.e. docked it) where it will set the Lat-Lon to the base.
[Not at computer to double-check.]