Advertisement
An93l0fD3ath

Loader Computer V4

Jul 25th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. local component = require("component")
  2. local serialize = require("serialization")
  3. local GERTi = require("GERTiClient")
  4. local colors = require("colors")
  5. local sides = require("sides")
  6.  
  7. local loaderInfo = component.proxy(component.get("7dfe"))
  8. local rs = component.redstone
  9. local myTable = loaderInfo.getFluidInTank(sides.down)
  10. local transposers = {}
  11. transposers["milk"] = component.proxy(component.get("8969"))
  12. transposers["sewage"] = component.proxy(component.get("9f87"))
  13.  
  14.  
  15. local socket = GERTi.openSocket(0.4, true, 1) --Tablet
  16. local socket = GERTi.openSocket(0.1, true, 1) --Holding_Bay
  17. local socket = GERTi.openSocket(0.2, true, 1) --SewagaePlant
  18.  
  19. local socket1 = nil -- Create 2 sockets that we're going to populate as connections come in
  20. local socket2 = nil -- See above
  21.  
  22. local function newConnection(eventname, origin, ID) -- This is a function that receives the 2 returned values by the event
  23.   if ID == 0.4 then
  24.     socket1 = GERTi.openSocket(origin, true, 0.4) -- If we're coming in from the tablet, open connection to tablet
  25.     elseif ID == 0.2 then
  26.     socket2 = GERTi.openSocket(origin, true, 0.2) -- If we're coming in from the sewage, open connection to sewage
  27.   end
  28. end
  29. event.listen("GERTConnectionID", newConnection) -- Register event handler
  30. -- We now have 2 bi-directional sockets opened
  31.  
  32.  
  33. local data = {}
  34. local function receiveData(eventname, origin, ID)
  35.   if ID == 0.4 then
  36.     data = socket1:read() --- If it's coming with the tablet connectionID, use the tablet socket
  37.   elseif ID == 0.2 then
  38.     data = socket2:read() --- If it's coming with the sewage connectionID, use the sewage socket
  39.   end
  40.   actData(data) -- Some imaginary function that acts on the data received
  41. end
  42.  
  43.  
  44. event.listen("GERTData", receiveData)
  45.  
  46.  
  47. serTable = data[1]
  48. receipt = serialize.unserialize(serTable)
  49. print(receipt)
  50.  
  51. local order = receipt["amount"]
  52. local fluid = receipt["type"]
  53.  
  54. local function cartRelease()
  55. myTable = loaderInfo.getFluidInTank(sides.down)
  56. rs.setBundledOutput(sides.east, colors.blue, 253)
  57. os.sleep(1)
  58. rs.setBundledOutput(sides.east, colors.blue, 0)
  59.  
  60. rs.setBundledOutput(sides.east, colors.blue, 253)
  61. os.sleep(1)
  62. rs.setBundledOutput(sides.east, colors.blue, 0)
  63.  
  64. print(myTable[1]["amount"],"cartRelease")
  65. end
  66.  
  67. local function loaderCheck()
  68. myTable = loaderInfo.getFluidInTank(sides.down)
  69. while myTable[1]["amount"] > 0 do
  70. print(myTable[1]["amount"],"loaderCheck1")
  71. cartRelease()
  72. os.sleep(70)
  73. end
  74.  
  75. end
  76.  
  77. local function getRemainder()
  78. if myTable[1]["amount"] <= 32000 then
  79. print(myTable[1]["amount"],"getRemainder")
  80. end
  81. end
  82.  
  83. transposers[fluid].transferFluid(sides.north, sides.south, order)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement