Advertisement
meuced

CapaPrinc

Sep 3rd, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. --Device detection
  2. isError=0
  3.  
  4. function detectDevice(DeviceName)
  5. DeviceSide="none"
  6. for k,v in pairs(redstone.getSides()) do
  7.  if peripheral.getType(v)==DeviceName then
  8.    DeviceSide = v
  9.    break
  10.  end
  11. end
  12.   return(DeviceSide)
  13. end
  14.  
  15. cell="none"
  16.  
  17. local peripheralList = peripheral.getNames()
  18.  
  19. CellSide=detectDevice("tile_enderio_blockcapacitorbank_name")
  20.  
  21. if CellSide~="none" then
  22.         cell=peripheral.wrap(CellSide)
  23.         print ("EnderIO capacitorbank on the " .. CellSide .. " connected.")
  24. else
  25.                 for Index = 1, #peripheralList do
  26.                         if string.find(peripheralList[Index], "cofh_thermalexpansion_energycell") then
  27.                                 cell=peripheral.wrap(peripheralList[Index])
  28.                                 print ("TE Energy cell on wired modem: "..peripheralList[Index].." connected.")
  29.                         elseif string.find(peripheralList[Index], "tile_enderio_blockcapacitorbank_name") then
  30.                                 cell=peripheral.wrap(peripheralList[Index])
  31.                                 print ("EnderIO capacitorbank on wired modem: "..peripheralList[Index].." connected.")
  32.                         end
  33.                 end --for
  34.                 if cell == "none" then
  35.                         print("No Energy storage found. Halting script!")
  36.                         return
  37.                 end
  38. end
  39.  
  40. message = {}
  41.  
  42. modem = peripheral.wrap("left")
  43.  
  44. while true do
  45.     --Get storage values
  46.         message["energy"] = cell.getEnergyStored("unknown")
  47.         message["maxenergy"] = cell.getMaxEnergyStored("unknown")
  48.         --print(message["energy"])
  49.         modem.open(200)
  50.         modem.transmit(200,200,textutils.serialize(message))
  51.         sleep(5)
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement