Advertisement
Guest User

marbles.lua

a guest
Nov 22nd, 2019
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. require('pack')
  2.  
  3. local winners = {}--4,21,637,4497,43222}
  4. local bags = {"Safe","Safe2","Locker","Satchel","Sack","Case","Inventory","Storage"}
  5. local folder_path = windower.windower_path .. '/scripts/marbles/'
  6. local player_name = windower.ffxi.get_player().name
  7.  
  8. if not windower.dir_exists(folder_path) then
  9.     windower.create_dir(folder_path)
  10. end
  11.  
  12. local make_file = io.open(folder_path .. '/%s.lua':format(player_name), 'w')
  13.  
  14. make_file:write('return {\n')
  15.  
  16. for _,bag in pairs(bags) do
  17.     for k,v in ipairs(windower.ffxi.get_items(bag)) do
  18.         if v and v.id == 2559 then
  19.             print(v.extdata:unpack('b17'))
  20.             make_file:write('    %s,\n':format(v.extdata:unpack('b17')))
  21.         end
  22.     end
  23. end
  24.  
  25. make_file:write('}\n')
  26. make_file:close()
  27.  
  28. if #winners == 0 then return end
  29.  
  30. local total = {0,0,0,0,0}
  31.  
  32. for _,f in pairs(windower.get_dir(folder_path)) do
  33.     local success, numbers = pcall(dofile,folder_path .. f)
  34.     if success then
  35.         for k,v in pairs(numbers) do
  36.             for x = 1, 5 do
  37.                 if v%(10^x) == winners[x] then
  38.                     local rank = math.abs(x-6)
  39.                     total[rank] = total[rank]+1
  40.                     windower.add_to_chat(207, 'Rank %d match found on %s. %d [%d]':format(rank,f:sub(1,-5),v,winners[x]))
  41.                 end
  42.             end
  43.         end
  44.     end
  45. end
  46.  
  47. for x = 1,5 do
  48.     if total[x] and total[x] > 0 then
  49.         windower.add_to_chat(207, 'total rank %s winners: %s':format(x,total[x]))
  50.     end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement