I receive no such error and the units are created in a circle when executing...
local function draw_circle_of_units(a,b,t,txt)
if txt == nil then txt = "" end
t = t - 1
lat1 = a.latitude
lon1 = a.longitude
lat2 = b.latitude
lon2 = b.longitude
dlat = math.abs(lat2-lat1)
dlon = math.abs(lon2-lon1)
r = math.sqrt(dlat*dlat + dlon*dlon)
for i=0,t-1 do
th = 2 * math.pi * i / t
rlat = lat1 + r * math.sin(th)
rlon = lon1 + r * math.cos(th)
ScenEdit_AddUnit({
side='PlayerSide',
type = 'Facility',
dbid = 62,
name=txt,
lat=rlat,
lon=rlon,
heading = th * 180.0 / 3.14159})
end
end
local unit = ScenEdit_GetUnit({name="Arty",side="China"}) --compiler flags this line
draw_circle_of_units({latitude=unit.latitude, longitude=unit.longitude},{latitude=unit.latitude + .1, longitude=unit.longitude}, 6, "EDSA 9/50");
So long as side "China" exists, and a unit "Arty" exists on that side.