Page 1 of 1
Syntax Error
Posted: Sun Jan 09, 2022 9:37 pm
by bearhunter007
I have used the following code with success in the old version ie. command: modern naval/air ops.
However with the new version I get the following:
ERROR: [string "Console"]:3: syntax error near 'u'
local u= ScenEdit_GetReferencePoint({guid='9QYU5K-0HMEJJLE87IL2'})
print u
I don't get what the error is referring too.
Thanks
RE: Syntax Error
Posted: Sun Jan 09, 2022 11:07 pm
by bearhunter007
Not content with dealing with the above issue I tried Jan Masterson's code for a circle of units
I get the following error: unexpected symbol near '<\226>'
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”)
I would appreciate any help since I never had this problem in the old CMANO program.
RE: Syntax Error
Posted: Mon Jan 10, 2022 5:12 am
by KnightHawk75
ORIGINAL: bearhunter007
I have used the following code with success in the old version ie. command: modern naval/air ops.
However with the new version I get the following:
ERROR: [string "Console"]:3: syntax error near 'u'
local u= ScenEdit_GetReferencePoint({guid='9QYU5K-0HMEJJLE87IL2'})
print u
I don't get what the error is referring too.
Thanks
print(u)
RE: Syntax Error
Posted: Mon Jan 10, 2022 5:20 am
by KnightHawk75
I receive no such error and the units are created in a circle when executing...
Code: Select all
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
Code: Select all
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.
RE: Syntax Error
Posted: Mon Jan 10, 2022 10:01 pm
by bearhunter007
Thanks for the feedback Knighthawk, it's been some time since I've used LUA.