Advertisement
MuChT007

powerPlantCapacitor V0.1

Feb 14th, 2021 (edited)
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. --Setup
  2. local modem = peripheral.wrap("back")
  3. local capacitorSide = "right"
  4. local cellType = 1 --basic,normal,vibrant
  5. local cells = 2
  6. local txChannel = 1400
  7. local rxChannel = 1410
  8. local production = "coal" --Where RF come from
  9.  
  10. --Variables
  11. local cellsCapacities = {1000000,5000000,25000000}
  12. local cellCapacity = (cellsCapacities[cellType]) * (cells)
  13. local capacitor_1 = peripheral.wrap(capacitorSide)
  14. local energyLevelOld = 0
  15. local typeOf = "capacitor"
  16.  
  17. while true do
  18.     --Get the capacitor datas
  19.     energyLevel = capacitor_1.getEnergyStored()
  20.     energyLevel = (energyLevel) * (cells)
  21.     term.clear()
  22.     print("Current energy storage is "..energyLevel.." RF")
  23.     print("capacity "..cellCapacity .." RF")
  24.     if energyLevel ~= energyLevelOld then
  25.         --prepare datas for sending to control room
  26.         data = {production,typeOf,cellCapacity,energyLevel}
  27.         --Sending to control room
  28.         modem.transmit(txChannel,rxChannel,textutils.serialize(data))
  29.         energyLevelOld = energyLevel
  30.     end
  31.     sleep(math.random(0,10))
  32.  
  33. end
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement