How to add a Satellite by using lua?

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
M1A2G
Posts: 29
Joined: Wed Sep 13, 2017 10:12 am

How to add a Satellite by using lua?

Post by M1A2G »

I entried this in the Lua Console:
ScenEdit_AddUnit({side='C',name='X',type='Satellite',dbid=70,orbit=15,lat='23',lon='112'})

It showed 'ScenEdit_AddUnit 0 : ,Unable to create new unit'.
Was it because of my wrong entrying or the function itself had a bug?[&:]
User avatar
stilesw
Posts: 1572
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: How to add a Satellite by using lua?

Post by stilesw »

M1A2G,

I just checked the online Lua reference (http://commandlua.github.io/index.html#Unit) and it looks like you should include the "NewUnit" parameter within the ScenEdit_AddUnit command.

ScenEdit_AddUnit
New unit selector.
... lists minimum fields required. Other fields from Unit may be included.

type string The type of unit (Ship, Sub, Aircraft, Facility, Satellite)
unitname string The name of the unit
side string The side name or GUID to add unit to
dbid number The database id of the unit
latitude Latitude Not required if a base is defined
longitude Longitude Not required if a base is defined
base string Unit base name or GUID where the unit will be 'hosted' (applicable to AIR, SHIP, SUB)
loadoutid number Aircraft database loadout id (applicable to AIR)
altitude number Unit altitude (applicable to AIR)
depth number Unit depth (applicable to SUBMARINE - note no sign)
orbit number Orbit index (applicable to SATELLITE)
guid string Optional custom GUID to override auto one

-Wayne

“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: How to add a Satellite by using lua?

Post by Whicker »

if you drop the orbit it works but it is non functional - looks like it is on the ground. What is orbit=15? where did you get that?

I don't see any examples of adding a satellite via lua, only thing I found was something about changing an existing ones orbit:
https://steamcommunity.com/app/321410/d ... 547730620/
Post Reply

Return to “Lua Legion”