Syntax Error

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
bearhunter007
Posts: 23
Joined: Sat Mar 11, 2017 2:51 am

Syntax Error

Post 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
bearhunter007
Posts: 23
Joined: Sat Mar 11, 2017 2:51 am

RE: Syntax Error

Post 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.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Syntax Error

Post 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)
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Syntax Error

Post 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.
bearhunter007
Posts: 23
Joined: Sat Mar 11, 2017 2:51 am

RE: Syntax Error

Post by bearhunter007 »



Thanks for the feedback Knighthawk, it's been some time since I've used LUA.
Post Reply

Return to “Lua Legion”