Gunner98
Posts: 5508
Joined: 4/29/2005 From: The Great White North! Status: offline
|
OK Just able to get back to this now: Getting an error: ERROR: [string "Console"]:32: '}' expected (to close '{' at line 26) near 'for' Played around with it for a while but no joy - any ideas? Tx ------------------------------------ function AddMultipleUnits() -- list of units to add -- there are 2 base types of elements in this table - unit and group -- unit: contains data for adding the unit, and optional group or mission data. the mission data is not used in this example. -- group: contains data for adding some group information. the group is assumed to have been created when it was assigned to a unit local newUnits = { {unit={type = 'Facility', name = 'Maribor main Runway', heading = 120, dbid = 55, side = 'Hugary', latitude='46.4803890511425', longitude='15.6878028852709'}, {unit={type = 'Facility', name = 'Maribor grass Runway', heading = 120, dbid = 945, side = 'Hugary', latitude='46.4814496219698', longitude='15.6896462040406'}, {unit={type = 'Facility', name = 'Maribor parking', dbid = 186, side = 'Hugary', latitude='46.4805743060371', longitude='15.6852357716592'}, {unit={type = 'Facility', name = 'Maribor parking', dbid = 186, side = 'Hugary', latitude='46.4804070784834', longitude='15.6854777981397'}, {unit={type = 'Facility', name = 'Maribor parking', dbid = 186, side = 'Hugary', latitude='46.4801134880231', longitude='15.6856922948778'}, {unit={type = 'Facility', name = 'Maribor parking', dbid = 186, side = 'Hugary', latitude='46.4796105298677', longitude='15.6864813619985'}, {unit={type = 'Facility', name = 'Maribor parking', dbid = 186, side = 'Hugary', latitude='46.4793804779242', longitude='15.6866653289655'}, {unit={type = 'Facility', name = 'Maribor parking', dbid = 186, side = 'Hugary', latitude='46.4792086519584', longitude='15.6867853295262'}, {unit={type = 'Facility', name = 'Maribor access', dbid = 306, side = 'Hugary', latitude='46.4804079946791', longitude='15.6865743476855'}, {unit={type = 'Facility', name = 'Maribor access', dbid = 306, side = 'Hugary', latitude='46.4798000404651', longitude='15.6871814779628'}, {unit={type = 'Facility', name = 'Maribor Control Twr', dbid = 3, side = 'Hugary', latitude='46.4793161568347', longitude='15.6851137247781'}, {unit={type = 'Facility', name = 'Maribor Hangar', dbid = 9, side = 'Hugary', latitude='46.4786876099595', longitude='15.68629942848'}, {unit={type = 'Facility', name = 'Maribor Ammo', dbid = 320, side = 'Hugary', latitude='46.4808465642364', longitude='15.6851757196959'}, {unit={type = 'Facility', name = 'Maribor Fuel', dbid = 944, side = 'Hugary', latitude='46.4782466613332', longitude='15.6881227119196'}, {unit={type = 'Facility', name = 'MANPADS', dbid = 416, side = 'Hugary', latitude='46.4821508520397', longitude='15.6832893809333'}, {unit={type = 'Facility', name = 'MANPADS', dbid = 416, side = 'Hugary', latitude='46.4768610848761', longitude='15.6848074901503'}, {unit={type = 'Facility', name = 'MANPADS', dbid = 416, side = 'Hugary', latitude='46.4793522402419', longitude='15.6913775009575'}, {unit={type = 'Facility', name = 'MANPADS', dbid = 416, side = 'Hugary', latitude='46.4834711133154', longitude='15.6877321512789'}, {unit={type = 'Facility', name = 'ZU-23-2', dbid = 2468, side = 'Hugary', latitude='46.4803890981919', longitude='15.684688367051'}, {unit={type = 'Facility', name = 'ZU-23-2', dbid = 2468, side = 'Hugary', latitude='46.4786662193619', longitude='15.6867238319341'}, {unit={type = 'Facility', name = 'ZU-23-2', dbid = 2468, side = 'Hugary', latitude='46.4802583518172', longitude='15.6899795108315'}, {unit={type = 'Facility', name = 'ZU-23-2', dbid = 2468, side = 'Hugary', latitude='46.4817310715893', longitude='15.6882468148245'}, {group={side='Hugary', name='Maribor Airbase',{latitude='46.4803890511425', longitude='15.6878028852709'}}}}, } -- process the table, adding the units to the scenario for i = 1, #newUnits, 1 do -- the table element .unit contains data?? if newUnits.unit ~= nil then print('adding #' .. i .. ' ' .. newUnits.unit.name) -- the table element .unit contains the data to pass as the parameter to the SE_AddUnit() function local u1 = ScenEdit_AddUnit( newUnits.unit ) -- check that the function worked. a 'unit' wrapper should be returned if u1 == nil then print( "failed to add unit") else -- does the same table entry contain an element .group. this is the group to assign unit to if newUnits.group ~= nil then u1.group=newUnits.group -- this will also create the group if it doesn't exist. end end elseif newUnits.group ~= nil then print('adding #' .. i .. ' ' .. newUnits.group.name) -- update the group with the data from the table local u1 = ScenEdit_SetUnit( newUnits.group ) if u1 == nil then print( "failed to add unit") end end end end
_____________________________
|