resaloli

BaseOS

Jun 3rd, 2014
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.99 KB | None | 0 0
  1. local bridge = peripheral.wrap("left")
  2. local net = peripheral.wrap("bottom")
  3. local tank1 = peripheral.wrap("iron_tank_valve_0")
  4. local tank2 = peripheral.wrap("iron_tank_valve_1")
  5. local massFabb = peripheral.wrap("advanced_machine_block_0")
  6. local modem = peripheral.wrap("bottom")
  7. modem.open(1)
  8. modem.transmit(1,1,'Prepare!')
  9. bridge.clear()
  10. term.clear()
  11.  
  12. print("Wraps Carregados!")
  13. sleep(0.5)
  14. print("Começando Programa!")
  15.  
  16. function debugTables()
  17.     lavaTable = tank1.getTanks("unknown")
  18.     lavatank = lavaTable[1]
  19.    
  20.     mobTable = tank2.getTanks("unknown")
  21.     mobtank = mobTable[1]
  22.    
  23. end
  24. debugTables()
  25.  
  26. local cores = {}
  27. cores.red = 0xff3333
  28. cores.blue = 0x7dd2e4
  29. cores.yellow = 0xffff4d
  30. cores.green = 0x4dff4d
  31. cores.gray = 0xe0e0e0
  32. cores.preto = 0x000000
  33.  
  34. function desenho()
  35.     bridge.clear()
  36.     local mainBox = caixa(20, 20, 145, 50, cores.gray, 0.5)
  37.     local outlineT = caixa(18,18,150,2,cores.blue,0.5)
  38.     local outlineB = caixa(18,70,150,2,cores.blue,0.5)
  39. end
  40.  
  41. function desenho1()
  42.     bridge.clear()
  43.     local mainBox = caixa(20, 20, 95, 50, cores.gray, 0.5)
  44.     local outlineT = caixa(18,18,100,2,cores.blue,0.5)
  45.     local outlineB = caixa(18,70,100,2,cores.blue,0.5)
  46. end
  47.  
  48. function menu()
  49.     bridge.clear()
  50.     desenho()
  51.     sleep(1)
  52.     texto(22, 22, "$$eneMJ = Energia MJ", cores.red)
  53.     texto(22, 32, "$$eneEU = Energia EU", cores.red)
  54.     texto(22, 42, "$$tankLava = Tank de Lava", cores.red)
  55.     texto(22, 52, "$$tankMob = Tank de Mob", cores.red)
  56.     texto(22, 62, "$$music = Musica Portal", cores.red)    
  57. end
  58.  
  59. function caixa(x, y, w, h, col, opa)
  60.   bridge.addBox(x,y,w,h,col,opa)
  61. end
  62.  
  63. function texto(x, y, text, col)
  64.   bridge.addText(x,y,text,col)
  65. end
  66.  
  67. function MJs()
  68. while true do
  69.   event, command = os.pullEvent("chat_command")
  70.     if command == "eneMJ" then
  71.       repeat
  72.             bridge.clear()
  73.             desenho1()
  74.             print(command)
  75.             local totalStorage = net.callRemote("redstone_energy_cell_0","getMaxEnergyStored")+net.callRemote("redstone_energy_cell_1","getMaxEnergyStored")
  76.             local freeStorage = net.callRemote("redstone_energy_cell_0","getEnergyStored")+net.callRemote("redstone_energy_cell_1","getEnergyStored")
  77.             local mjIndicator = (freeStorage/totalStorage) * 50
  78.             texto(22, 22, "MJ Storage", cores.red)
  79.             texto(22, 32, freeStorage.."/"..totalStorage, cores.green)
  80.             sleep(2)
  81.         until command ~= "eneMJ"
  82.     end
  83.   end
  84. end
  85.  
  86. function EUs()
  87.     while true do
  88.         event, command = os.pullEvent("chat_command")
  89.         if command == "eneEU" then
  90.         repeat
  91.             bridge.clear()
  92.             desenho1()
  93.             print(command)
  94.             local totalStorage = net.callRemote("batbox_0","getCapacity")
  95.             local freeStorage = net.callRemote("batbox_0","getStored")
  96.             local euIndicator = (freeStorage/totalStorage) * 50
  97.             texto(22, 22, "EU Storage", cores.red)
  98.             texto(22, 32, freeStorage.."/"..totalStorage, cores.green)
  99.             sleep(2)
  100.         until command ~= "eneEU"
  101.     end
  102.   end
  103. end
  104.  
  105. function tankL()
  106.     while true do
  107.         event, command = os.pullEvent("chat_command")
  108.         if command == "tankLava" then
  109.         repeat
  110.             bridge.clear()
  111.             desenho1()
  112.             print(command)
  113.             local totalStorage = lavatank.capacity
  114.             local freeStorage = lavatank.amount
  115.             local lavaIndicator = (freeStorage/totalStorage) * 50
  116.             texto(22, 22, "Lava Storage", cores.red)
  117.             texto(22, 32, freeStorage.."/"..totalStorage, cores.green)
  118.             sleep(2)
  119.         until command ~= "tankLava"
  120.     end
  121.   end
  122. end
  123.  
  124. function tankM()
  125.     while true do
  126.         event, command = os.pullEvent("chat_command")
  127.         if command == "tankMob" then
  128.         repeat
  129.             bridge.clear()
  130.             desenho1()
  131.             print(command)
  132.             local totalStorage = mobtank.capacity
  133.             local freeStorage = mobtank.amount
  134.             local mobIndicator = (freeStorage/totalStorage) * 50
  135.             texto(22, 22, "Mob Ess. Storage", cores.red)
  136.             texto(22, 32, freeStorage.."/"..totalStorage, cores.green)
  137.             sleep(2)
  138.         until command ~= "tankMob"
  139.     end
  140.   end
  141. end
  142.  
  143. function massFab()
  144.     while true do
  145.         event, command = os.pullEvent("chat_command")
  146.         if command == "massFab" then
  147.         repeat
  148.             bridge.clear()
  149.             desenho1()
  150.             print(command)            
  151.             if  massFabb.getStackInSlot(2) == nil then
  152.                 uuMatter = 0
  153.             else
  154.                 uuMatterTable = massFabb.getStackInSlot(2)
  155.                 uuMatter = uuMatterTable["qty"]
  156.             end
  157.            
  158.             if  massFabb.getStackInSlot(1) == nil then
  159.                 amplificador = 0
  160.             else
  161.                 amplificadorTable = massFabb.getStackInSlot(1)
  162.                 amplificador = amplificadorTable["qty"]
  163.             end
  164.             local progress = massFabb.getProgressAsString()
  165.             texto(22, 22, "MassFab", cores.red)
  166.             texto(22, 32, uuMatter.."/64", cores.green)
  167.             texto(22, 42, "Progresso: "..progress, cores.green)
  168.             texto(22, 52, "Amplificador: "..amplificador, cores.green)
  169.             sleep(2)
  170.         until command ~= "massFab"
  171.     end
  172.   end
  173. end  
  174.  
  175. function music()
  176.     while true do
  177.         event, command = os.pullEvent("chat_command")
  178.         if command == "music" then
  179.             print(command)
  180.             local jukebox = peripheral.wrap("auto-jukebox_0")
  181.             jukebox.playRecord()
  182.         end
  183.     end
  184. end
  185.  
  186. function start()
  187.     while true do
  188.         event, command = os.pullEvent("chat_command")
  189.         if command == "start" then
  190.             print(command)
  191.             bridge.clear()
  192.             menu()
  193.         end
  194.     end
  195. end
  196.  
  197. function secOn()
  198.     while true do
  199.         event, command = os.pullEvent("chat_command")
  200.         if command == "secOn" then
  201.             print(command)
  202.             modem.transmit(1, 1, "SecON")
  203.         end
  204.     end
  205. end
  206.  
  207. function secOff()
  208.     while true do
  209.         event, command = os.pullEvent("chat_command")
  210.         if command == "secOff" then
  211.             print(command)
  212.             modem.transmit(1, 1, "SecOFF")
  213.         end
  214.     end
  215. end
  216.  
  217. function secState()
  218.     while true do
  219.         event, command = os.pullEvent("chat_command")
  220.         if command == "secState" then
  221.         repeat
  222.                 bridge.clear()
  223.                 desenho1()
  224.                 print(command)
  225.                 modem.transmit(1, 1, "SecState")
  226.                 local _, side, freq, rfreq, message = os.pullEvent('modem_message')
  227.                 print(message)
  228.                 texto(22, 22, "Sec State", cores.red)
  229.                 texto(22, 32, "Estado: "..message, cores.green)
  230.                 sleep(2)
  231.         until command ~= "secState"
  232.     end
  233.   end
  234. end
  235.  
  236. function checkCommand()
  237.     while true do
  238.         local event, command = os.pullEvent("chat_command")
  239.   end
  240. end
  241.  
  242. print("Dados Carregados")
  243. sleep(1)
  244. print("Programa Pronto")
  245. menu()
  246. parallel.waitForAny(music, massFab, start , MJs, EUs, tankL, tankM, secState, secOn, secOff, checkCommand)
Add Comment
Please, Sign In to add comment