Advertisement
Terrah

test

Nov 24th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function testprt(tbl)
  2.  
  3.     for k,v in pairs(tbl)do
  4.         print(tostring(k)..": " ..tostring(v));
  5.     end
  6. end
  7.  
  8. local function Merge(tbl,tbl2)
  9.     testprt(tbl2);
  10. end
  11.  
  12. local function RawLadderRequest(leaguename,entries)
  13.  
  14.     local cnt = 0;
  15.     local request = entries;
  16.     local ladder = false;
  17.     local current = false;
  18.     local actual = entries;
  19.  
  20.     while(entries>=cnt)do
  21.  
  22.         if actual> 200 then
  23.             actual= 200;
  24.         end
  25.  
  26.         local req = "http://api.pathofexile.com/ladders/"..leaguename:gsub("/","%%2F").."?offset="..tostring(cnt).."&limit="..tostring(actual);
  27.  
  28.         print(req);
  29.  
  30.         cnt = cnt + actual;
  31.         request = request - actual;
  32.         actual = request;
  33.  
  34.         current = JSONDecode(MOD.HTTPGet(req));
  35.  
  36.         if not current then
  37.             return nil;
  38.         end
  39.  
  40.         if(not ladder)then
  41.             ladder = current;
  42.             testprt(ladder.entries);           
  43.         else
  44.             Merge(ladder,current);
  45.         end
  46.  
  47.         if(entries>=ladder.total)then
  48.             return ladder;
  49.         end                
  50.     end
  51.     return ladder;
  52. end
  53.  
  54. return RawLadderRequest("One Week HC Rampage/Beyond",300);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement