Advertisement
Alakazard12

AltProto_DraconicStorage

Mar 11th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local storage = peripheral.find("draconic_rf_storage")
  2.  
  3.  
  4. OnEvent(function(event, side)
  5.     if not storage and peripheral.getType(side) == "draconic_rf_storage" then
  6.         storage = peripheral.wrap(side)
  7.         Log("Storage attached")
  8.     end
  9. end, "peripheral")
  10.  
  11.  
  12. OnMessage(function(id, recipient, sender, data)
  13.     if storage then
  14.         SendMessage("RES_EN", sender, {
  15.             stored = storage.getEnergyStored();
  16.             max = storage.getMaxEnergyStored()
  17.         })
  18.     end
  19. end, "REQ_EN")
  20.  
  21.  
  22. OnEvent(function(event, side)
  23.     if storage and peripheral.getType(side) == "draconic_rf_storage" then
  24.         storage = nil
  25.         Log("Storage detached")
  26.     end
  27. end, "peripheral_detach")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement