Syntax Error (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


bearhunter007 -> Syntax Error (1/9/2022 11:37:37 PM)

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 -> RE: Syntax Error (1/10/2022 1:07:07 AM)

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 -> RE: Syntax Error (1/10/2022 7:12:51 AM)


quote:

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 -> RE: Syntax Error (1/10/2022 7:20:30 AM)

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.




bearhunter007 -> RE: Syntax Error (1/11/2022 12:01:34 AM)



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




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.8125