Advertisement
Link712011

xp_consumer

Oct 7th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. local net = require('net')
  2. local utilities = require('utilities')
  3.  
  4. local component = require('component')
  5. local robot = require('robot')
  6.  
  7. local arg = {...}
  8.  
  9. local PASTE_URL = 'https://pastebin.com/raw/mXkLDR54'
  10. local FILEPATH = 'xp_consumer'
  11.  
  12. function print_experience()
  13.     print(utilities.round(component.experience.level(), 2))
  14. end
  15.  
  16. function update()
  17.     print('Updating...')
  18.     if net.get_page_to_file(PASTE_URL, FILEPATH) then
  19.         print('Updated successfully.')
  20.         return true
  21.     end
  22.     print('Failed to update.')
  23.     return false
  24. end
  25.  
  26. function parse_inv()
  27.     local slot
  28.  
  29.     slot = robot.inventorySize()
  30.     while slot > 0 do
  31.         robot.select(slot)
  32.         if component.experience.consume() then
  33.             print_experience()
  34.         end
  35.         robot.dropDown()
  36.         slot = slot - 1
  37.     end
  38. end
  39.  
  40. function get_stuff()
  41.     local moved
  42.  
  43.     moved = false
  44.     while robot.suckUp() do
  45.         moved = true
  46.     end
  47.     return moved
  48. end
  49.  
  50. function core()
  51.     print_experience()
  52.     parse_inv()
  53.     while get_stuff() do
  54.         parse_inv()
  55.     end
  56. end
  57.  
  58. if arg[1] and (arg[1] == '-u' or arg[1] == '--update') then
  59.     return update()
  60. end
  61.  
  62. core()
  63. return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement