No ship with ID?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

No ship with ID?

Post 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
Attachments
Papaproblem.jpg
Papaproblem.jpg (109.54 KiB) Viewed 251 times
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: No ship with ID?

Post 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.
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: No ship with ID?

Post by Gunner98 »

Thanks TT - works like a charm

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: No ship with ID?

Post 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.



User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: No ship with ID?

Post 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.]
Michael
Post Reply

Return to “Lua Legion”