Advertisement
Guest User

1

a guest
Jul 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. sen = sensor.wrap("bottom")
  3. mon = peripheral.wrap("back")
  4. mon.setTextScale(1)
  5.  
  6. xMax, yMax = mon.getSize()
  7.  
  8. tps=30
  9. x=1
  10. y=-2
  11. z=0
  12.  
  13. function JoJa()
  14.   mon.setBackgroundColor(colors.gray)
  15.   for xP = 1,xMax do
  16.     mon.setCursorPos(xP,1)
  17.     mon.write(" ")
  18.   end
  19.   mon.setCursorPos(1,1)
  20.   mon.setTextColor(colors.cyan)
  21.   mon.write("Jo")
  22.   mon.setTextColor(colors.orange)
  23.   mon.write("Ja ")
  24.   mon.setTextColor(colors.lightGray)
  25.   mon.write("Productions")
  26. end
  27.  
  28. function bg(col)
  29.   mon.setBackgroundColor(col)
  30.   for xP = 1,xMax do
  31.     for yP = 1,yMax do
  32.       mon.setCursorPos(xP,yP)
  33.       mon.write(" ")
  34.     end
  35.   end
  36. end
  37.  
  38.  
  39. energy=0
  40. energynew=0
  41. energytick=0
  42. energytotal=0
  43. tickstotal=0
  44. while true do
  45.   targets = sen.getTargets()
  46.   for k,v in pairs(targets) do
  47.     if  v.Position.X==x  and v.Position.Y==y
  48.     and v.Position.Z==z then
  49.       for w,x in pairs(sen.getTargetDetails(k)) do
  50.         if w == "EnergySunken" then
  51.           energynew = x
  52.         end
  53.       end
  54.     end
  55.   end
  56.  
  57.   bg(colors.lightGray)
  58.   JoJa()
  59.   mon.setTextColor(colors.white)
  60.   mon.setBackgroundColor(colors.lightGray)
  61.  
  62.  
  63.   if energy == 0 then
  64.     energy = energynew
  65.    
  66.     mon.setCursorPos(1,3)
  67.     mon.write("EU/t       0EU/t")
  68.     mon.setCursorPos(1,4)
  69.     mon.write("Mittelwert 0EU/t")
  70.   elseif energynew >= energy then
  71.     energytick = (energynew - energy) / tps
  72.     energytotal = energytotal + energytick
  73.     energy = energynew
  74.     tickstotal = tickstotal + 1
  75.    
  76.     mon.setCursorPos(1,3)
  77.     mon.write("EU/t       " .. math.floor(energytick) .. "EU/t")
  78.     mon.setCursorPos(1,4)
  79.     mon.write("Mittelwert " .. math.floor(energytotal / tickstotal) .. "EU/t")
  80.   else
  81.     energytick = 0
  82.     energy = 0
  83.     energynew = 0
  84.     tickstotal = 0
  85.    
  86.     mon.setCursorPos(1,3)
  87.     mon.write("Neuberechnung...")
  88.   end
  89.  
  90.   sleep(1)  
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement