I have the below code that when run ends up giving me
Code: Select all
ERROR: Sequence contains no matching elementI don't know where I goofed and if its syntax or somewhere else. I snagged this from another online git or site and added my own details and units but I cant remember where. The purpose is to randomize the starting locations of the US FARPs for a SCS scenario I'm developing. I would appreciate any help!
i had to omit the lat and long to post bc im less than 10 posts and it thought it was a phone#
Code: Select all
math.randomseed(os.time())
math.random(); math.random(); math.random()
a = math.random(1,3)
b = math.random(1,3)
local distanceJitter = .3 -- varies the distance between units so it is not a perfect grid
local angleJitter =.3 -- varies the angle used to place units so it is not a perfect grid
function WW_CreateAirBase(basename,latlonTable, runways, taxiways, accesspoints, tarmacspaces, ammopads)
local lat=latlonTable['latitude']
local lon=latlonTable['longitude']
for i=1,runways do
local u = ScenEdit_AddUnit({side='Abandoned', type='Facility', name='Runway '..i, dbid=55, autodetectable=true, Lat=lat, Lon=lon})
u.group =basename
lat=lat +.004
end --runways
lat=latlonTable['latitude'] --reset lat and add to lon
lon=latlonTable['longitude'] + .002
for i=1,taxiways do
local u = ScenEdit_AddUnit({side='United States', type='Facility', name='Taxiway '..i, dbid=1424, autodetectable=true, Lat=lat, Lon=lon})
u.group =basename
lat=lat +.004
end
lat=latlonTable['latitude'] --reset lat and add to lon
lon=latlonTable['longitude'] + .004
for i=1,accesspoints do
local u = ScenEdit_AddUnit({side='United States', type='Facility', name='Access Point '..i, dbid=353, autodetectable=true, Lat=lat, Lon=lon})
u.group =basename
lat=lat +.004
end
lat=latlonTable['latitude'] --reset lat and add to lon
lon=latlonTable['longitude'] + .006
for i=1,accesspoints do
local u = ScenEdit_AddUnit({side='United States', type='Facility', name='Tarmac Space '..i, dbid=344, autodetectable=true, Lat=lat, Lon=lon})
u.group =basename
lat=lat +.002
end
lat=latlonTable['latitude'] --reset lat and add to lon
lon=latlonTable['longitude'] + .008
for i=1,ammopads do
local u = ScenEdit_AddUnit({side='United States', type='Facility', name='Ammo Pad '..i, dbid=1496, autodetectable=true, Lat=lat, Lon=lon})
u.group =basename
lat=lat +.002
end
end
if a == 1 then
WW_CreateAirBase('MEU FARP South',{latitude='xxxxxxxxx', longitude='xxxxxxxxx'},2,2,4,8,2)
elseif a == 2 then
WW_CreateAirBase('MEU FARP South',{latitude='xxxxxxxxx', longitude='xxxxxxxxx'},2,2,4,8,2)
elseif a == 3 then
WW_CreateAirBase('MEU FARP South',{latitude='xxxxxxxxx', longitude='xxxxxxxxx'},2,2,4,8,2)
end
if b == 1 then
WW_CreateAirBase('MEU FARP North',{latitude='xxxxxxxxxxx', longitude='xxxxx'},2,2,4,8,2)
elseif b == 2 then
WW_CreateAirBase('MEU FARP North',{latitude='xxxxxxxxx', longitude='xxxxxx'},2,2,4,8,2)
elseif b ==3 then
WW_CreateAirBase('MEU FARP North',{latitude='xxxxxx', longitude='xxxxxx'},2,2,4,8,2)
end