Advertisement
Guest User

Untitled

a guest
Jul 26th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local robot = require("robot")
  4. local db = component.database
  5. local invcontrol = component.inventory_controller
  6.  
  7. function gib(gibber)
  8. print(db.get(gibber))
  9. print(db.computeHash(gibber))
  10. end
  11.  
  12. function drop(dropper)
  13. robot.select(1)
  14. invcontrol.dropIntoSlot(1, dropper)
  15. end
  16.  
  17. function check()
  18. invcontrol.store(1, _G.slot, db.address, 1)
  19. local checkret = db.computeHash(1)
  20. --print(checkret)
  21. return(checkret)
  22. end
  23.  
  24. function isEmpty()
  25. if(string.find(check(), _G.empty) == nil)
  26. then
  27. --print("Not Empty!")
  28. return(false)
  29. else
  30. print("Empty!")
  31. return(true)
  32. end
  33. end
  34.  
  35. function main()
  36. if(isEmpty() == true)
  37. then
  38. charge()
  39. else
  40. main()
  41. end
  42. end
  43.  
  44. function charge()
  45. print("Charging!")
  46. invcontrol.suckFromSlot(1, _G.slot)
  47. invcontrol.dropIntoSlot(3,1)
  48. pull()
  49. end
  50.  
  51. function pull()
  52. print("checkin")
  53. if(invcontrol.getStackInInternalSlot(1) == nil)
  54. then
  55. fucklua()
  56. else
  57. print("Charged!")
  58. invcontrol.suckFromSlot(3,2)
  59. invcontrol.dropIntoSlot(1, _G.slot)
  60. main()
  61. end
  62. end
  63.  
  64. function fucklua()
  65. pull()
  66. end
  67.  
  68.  
  69. io.write("Welcome to Railgun Reload! Please input the # of the hotbar slot you are going to use for your railgun: ")
  70. io.flush()
  71. _G.slot = tonumber(io.read())
  72.  
  73. repeat
  74. io.write("Please place your UNCHARGED railgun in the slot you selected, type 'ok' when you are ready to continue")
  75. io.flush()
  76. until io.read() == "ok"
  77.  
  78. invcontrol.store(1, _G.slot, db.address, 2)
  79. _G.empty = db.computeHash(2)
  80. db.clear(2)
  81.  
  82. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement