Advertisement
EmidioMata

Reactor

Aug 15th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sideofreac
  2. local sideofmon
  3. local max
  4. local min
  5. local reactor
  6. local monitor
  7. local maxstored
  8. loacl scale
  9.  
  10.  
  11. function createsettings()
  12.         local settings={}
  13.         print("Side of Reactor")
  14.         settings[1]=read()
  15.         print("Side of Monitor:")
  16.         settings[2]=read()
  17.         print("Max Amount of Energy Stored want (in /%):")
  18.         settings[3]=tonumber(read())
  19.         print("Min Amount of Energy Stored you want (in /%):")
  20.         settings[4]=tonumber(read())
  21.         print("Max Amount of Energy Stored of the Reactor (in RF):")
  22.         settings[5]=tonumber(read())
  23.         print("Scale:")
  24.         settings[6]=tonumber(read())
  25.         save(settings,"settings.txt")
  26. end
  27.  
  28. function loadsettings()
  29.         local settings=load("settings.txt")
  30.         sideofreac=settings[1]
  31.     sideofmon=settings[2]
  32.     max=settings[3]
  33.     min=settings[4]
  34.     maxstored=settings[5]
  35.     scale=settings[6]
  36. end
  37.  
  38. function split(inputstr, sep)
  39.         if sep == nil then
  40.                 sep = "%s"
  41.         end
  42.         local t
  43.         for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  44.                 t = str
  45.         break
  46.         end
  47.         return t
  48. end
  49.  
  50. function save(table,name)
  51.         local file = fs.open(name,"w")
  52.         file.write(textutils.serialize(table))
  53.         file.close()
  54. end
  55.  
  56. function load(name)
  57.         local file = fs.open(name,"r")
  58.         local data = file.readAll()
  59.         file.close()
  60.         return textutils.unserialize(data)
  61. end
  62.  
  63. function setup()
  64. local cable=peripheral.wrap("sideofmon")
  65. local names=cable.getNamesRemote()
  66. for i=1,#names do
  67.     if string.sub(names[i],1,2)=="mon" then
  68.         monitor=names[i]
  69.     end
  70. end
  71. local cable=peripheral.wrap("sideofreac")
  72. local names=cable.getNamesRemote()
  73. for i=1,#names do
  74.     if string.sub(names[i],1,2)=="Big" then
  75.         reactor=names[i]
  76.     end
  77. end
  78. end
  79.  
  80. function display()
  81. mon=peripheral.wrap(monitor)
  82. reac=peripheral.wrap(reactor)
  83. local l,h=mon.getSize()
  84. local stored=rea.getEnergyStored()
  85. local info={"","Energy Output:",tostring(rea.getEnergyProducedLastTick()),"","Temperature",split(tostring(rea.getFuelTemperature(),","),"","Fuel Burnout",tostring(rea.getFuelConsumedLastTick())}
  86. local used=0
  87. for i=1,#info do
  88.     if used > string.len(info[i]) then
  89.     used = string.len(info[i])
  90.     end
  91.     if i==#info then l-used end
  92. end
  93. for i=1,#info do
  94.     mon.write(info[i],1,i)
  95. end
  96. end
  97.  
  98. local hsize=l*0,60
  99. local lsize=(h-10)
  100.  
  101.  
  102.  
  103.  
  104. ---------------------------------------------------
  105. if not exist("settings.txt") then
  106.         createsettings()      
  107. end
  108. loadsettings()
  109. setup()
  110.  
  111.  
  112.  
  113.  
  114. while true do
  115.                display()
  116. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement