Signup Now
Results 1 to 2 of 2
  1. #1
    Free User
    Join Date
    Feb 2016
    Posts
    3
    Reputation
    10
    Rep Power
    0

    Question [question] array as function argument

    Hello.

    Is this possible send to function array as first parametr?

    function gotoBestLabel( section, a, b, z, ...)
    local labels = ...
    local section = section or false
    if type(section) == 'string' then gotolabel(0,section) end
    local a = a or $posx
    local b = b or $posy
    local z = z or $posz
    local wptinfo = {}
    local distance = {}

    for _,lab in ipairs(labels) do
    foreach settingsentry s 'Cavebot/Waypoints' do
    if get(s, 'Label') == lab then
    xyz = get(s, 'Coordinates')
    x1,y1,_ = string.match(xyz,'x:(%d+), y:(%d+), z:(%d+)')
    end
    end
    if tilereachable( x1, y1, z, true ) then
    table.insert( wptinfo, {id = getwptid(labels[v]), label = lab, x = x1, y = y1, dist = getdistancebetween(x1, y1, z, a, b, z)})
    table.insert( distance, getdistancebetween(x1, y1, z, a, b, z) )
    end
    end
    local min = table.min(distance)
    for _,lab in pairs(wptinfo) do
    if lab.dist == min then
    return lab.label--gotolabel(lab.id)
    end
    end
    end


    when i got this i must run all time
    gotoBestLabel( nil, nil, nil, nil, {'A','B','C'})

    but i want
    gotoBestLabel( {'A','B','C'})
    Last edited by atomowabetty; 02-24-2016 at 02:03 PM.

  2. #2
    Wind Tester
    Join Date
    Dec 2013
    Location
    Warsaw, Poland
    Posts
    2,579
    Reputation
    149
    Rep Power
    27
    cant you just pass array ( {'asd', 'fgf', 'vcxzv'} instead of multiple arguments ('asd', 'dsfsd', 'gdfsgf')?

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •