Advertisement
Guest User

startup

a guest
Dec 17th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. local m = peripheral.wrap("monitor_66")
  2. local r = peripheral.wrap("back")
  3. local m_lu = 0
  4. m.setTextScale(1)
  5. function draw()
  6.   m.setCursorPos(1,1)
  7.   m.setBackgroundColor(32768)
  8.   m.setTextColor(1)
  9.   m.clear()
  10.  
  11.   m.setBackgroundColor(2048)
  12.   m.clearLine()
  13.   m.setBackgroundColor(128)
  14.  
  15.   for i=2,22,1 do
  16.     m.setCursorPos(1, i)
  17.     m.clearLine()
  18.   end
  19.  
  20.   m.setCursorPos(1,1)
  21.   m.setBackgroundColor(2048)
  22.   if r == nil then
  23.     m.setTextColor(16384)
  24.     m.write("NOT CONNECTED")
  25.   else
  26.     if r.getConnected() then
  27.       m.setTextColor(2)
  28.       m.write("Status")
  29.       if r.getActive() then
  30.         m.setCursorPos(14,1)
  31.         m.setTextColor(8192)
  32.         m.write("AKTIV")
  33.       else
  34.         m.setCursorPos(12,1)
  35.         m.setTextColor(16384)
  36.         m.write("INAKTIV")
  37.       end
  38.      
  39.       m.setTextColor(1)
  40.       m.setCursorPos(1,3)
  41.       m.setBackgroundColor(128)
  42.       m.write("Reaktor ")
  43.      
  44.       if r.getActive() then
  45.         m.setTextColor(16384)
  46.         m.write("DEAKTIVIEREN")
  47.       else
  48.         m.setTextColor(8192)
  49.         m.write("AKTIVIEREN")
  50.       end
  51.      
  52.       m.setCursorPos(1,4)
  53.       m.setTextColor(1)
  54.       m.write("Brennstaebe: ")
  55.       m.setTextColor(2)
  56.       m.write(r.getNumberOfControlRods())
  57.      
  58.       m.setCursorPos(1,6)
  59.       m.setTextColor(1)
  60.       m.write("Energie: ")
  61.       m.setTextColor(2048)
  62.       m.write(r.getEnergyStored() .. "RF")
  63.      
  64.       m.setCursorPos(1,5)
  65.       m.setTextColor(1)
  66.       m.write("Fuel: ")
  67.       m.setTextColor(2)
  68.       m.write(r.getFuelAmount() / 1000)
  69.      
  70.       local perc = math.floor((r.getFuelAmount() / r.getFuelAmountMax()) * 100)
  71.       m.write(" [" .. perc .. "%]")
  72.      
  73.      
  74.      
  75.       m.setCursorPos(1,12)
  76.       m.setTextColor(1)
  77.       m.write("Beenden")
  78.     else
  79.       m.setTextColor(16384)
  80.       m.write("NOT CONNECTED")
  81.     end
  82.   end
  83. end
  84.  
  85. draw()
  86. while true do
  87. os.startTimer(0.5)
  88.   local ev, btn, x, y = os.pullEvent()
  89.   if ev == "monitor_touch" then
  90.     if y == 3 and x >=9 and x <= 19 then
  91.       r.setActive(not r.getActive())
  92.     elseif y == 12 and x >= 1 and x <= 8 then
  93.       m.setBackgroundColor(32768)
  94.       m.clear()
  95.       error()
  96.     end
  97.   elseif ev == "timer" then
  98.     draw()
  99.   end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement