Page 1 of 1

How to add a Satellite by using lua?

Posted: Sun May 19, 2019 11:39 am
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?[&:]

RE: How to add a Satellite by using lua?

Posted: Sun May 19, 2019 12:58 pm
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


RE: How to add a Satellite by using lua?

Posted: Sun May 19, 2019 1:46 pm
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/