WoW:USERAPI GetReturnValues: Difference between revisions

m
→‎Code: Still inefficient, but not as bad.
mNo edit summary
m (→‎Code: Still inefficient, but not as bad.)
Line 42: Line 42:


  function {{PAGENAME}}(order, ...)
  function {{PAGENAME}}(order, ...)
    local input = {...}
     local output = {}
     local output = {}
     order = tostring(order);
     order = tostring(order)
     for i=1, strlen(order) do
     for i=1, strlen(order) do
         local key = tonumber(strsub(order, i, i));
         local value = select(tonumber(strsub(order, i, i), ...)
         if input[key] ~= nil then
         if value ~= nil then
             table.insert(output, input[key]);
             table.insert(output, value)
         end
         end
     end
     end
     return unpack(output);
     return unpack(output)
  end
  end
Variant
Variant
local {{PAGENAME}}_In;
  local {{PAGENAME}}_Out
  local {{PAGENAME}}_Out;
  function {{PAGENAME}}(order, ...)
  function {{PAGENAME}}(order, ...)
    {{PAGENAME}}_In = {...}
     {{PAGENAME}}_Out = {}
     {{PAGENAME}}_Out = {}
     order = tostring(order);
     order = tostring(order)
     for i=1, strlen(order) do
     for i=1, strlen(order) do
         local key = tonumber(strsub(order, i, i));
         local value = select(tonumber(strsub(order, i, i)), ...)
         if {{PAGENAME}}_In[key] ~= nil then
         if value ~= nil then
             table.insert({{PAGENAME}}_Out, {{PAGENAME}}_In[key]);
             table.insert({{PAGENAME}}_Out, value)
         end
         end
     end
     end
     return unpack({{PAGENAME}}_Out);
     return unpack({{PAGENAME}}_Out)
  end
  end


__NOTOC__
__NOTOC__
[[Category:User Defined Functions]]
[[Category:User Defined Functions]]
Anonymous user