Advertisement
Guest User

easy.lua

a guest
Apr 5th, 2020
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.86 KB | None | 0 0
  1. local comp = require("component")
  2. local filesystem = require("filesystem")
  3. local keyboard = require("keyboard")
  4. local event = require("event")
  5. local gpu = comp.gpu
  6. local reactors = {}
  7. local red =  0xC14141
  8. local blue =   0x4286F4
  9. local yellow = 0xffdb4d
  10. local white =  0xFFFFFF
  11. local black =  0x000000
  12. local height, width = gpu.getResolution()
  13. local reactors = {}
  14. local firstreactor
  15. local energy
  16. local maxEng = 10000000
  17. local maxFuel = 100000 --- not correct value change later--
  18. local widJump = width/100
  19. local heJump =  height/100
  20. local breite = math.ceil(20*widJump)
  21.   local hohe = math.ceil(80*heJump)
  22.   xcoordout= math.floor(10*widJump)
  23.   xcoordout2= math.floor(40*widJump)
  24.   ycoordout= math.floor(10*heJump)
  25.   xcoordin = math.floor(15*widJump)
  26.   xcoordin2 = math.floor(45*widJump)
  27.   ycoordin = math.floor(11*heJump)
  28.  
  29.  
  30. ---getReactor---
  31. function getReactor()
  32.   local i = 1
  33.   for adr, type in comp.list("br_reactor") do
  34.     reactors[i] = comp.proxy(adr)
  35.   end
  36.   firstreactor = reactors[1]
  37.  
  38.  
  39. end
  40.  
  41. ---energyControl----
  42. function energyControl()
  43.    energy = firstreactor.getEnergyStored()
  44.   if energy >= 0.9* maxEng then
  45.  
  46.       firstreactor.getActive(false)
  47.   end
  48.   if energy <= 0.1*maxEng then
  49.       firstreactor.getActive(true)
  50.   end
  51.  energyProz = energy/maxEng
  52.  gpu.setBackground(red)
  53.   gpu.setForeground(red)
  54. gpu.fill( math.floor(15*widJump),height,breite - 7*widJump,-ycoordin * energyProz," ")  
  55. end
  56. ----fuelControl----
  57. function fuelControl()
  58. fuel = firstreactor.getFuelAmount()
  59.     fuelproz = fuel/maxFuel
  60. gpu.setBackground(blue)
  61. gpu.setForeground(blue)
  62. gpu.fill(math.floor(45*widJump),height-math.floor(height*fuelproz),breite - 7*widJump,hohe- 50* heJump," ")
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. end
  70.  
  71.  
  72. ---drawBars---
  73. function drawBars()
  74.   local breite = math.ceil(20*widJump)
  75.   local hohe = math.ceil(80*heJump)
  76.   xcoordout= math.floor(10*widJump)
  77.   xcoordout2= math.floor(40*widJump)
  78.   ycoordout= math.floor(10*heJump)
  79.   xcoordin = math.floor(15*widJump)
  80.   xcoordin2 = math.floor(45*widJump)
  81.   ycoordin = math.floor(11*heJump)
  82.   gpu.setForeground(white)
  83.   gpu.set(xcoordin, ycoordout -4 *heJump,"Energy")
  84.   gpu.set(xcoordin2,ycoordout-4 * heJump,"Fuel")--- maybe change values for height
  85.   gpu.setBackground(yellow)
  86.   gpu.setForeground(yellow)
  87.   gpu.fill(xcoordout,ycoordout,breite,hohe," ")
  88.   gpu.fill(xcoordout2, ycoordout, breite, hohe," ")
  89.   gpu.setBackground(black)
  90.   gpu.setForeground(black)
  91.   gpu.fill(xcoordin,ycoordin,breite - 7*widJump,hohe- 50* heJump," ")
  92.   gpu.fill(xcoordin2,ycoordin,breite - 7*widJump,hohe- 50* heJump," ")
  93.  
  94.  
  95.  
  96. end
  97. ----text---
  98. function text(x,y,texts,col,bg_color)
  99.  gpu.setBackground(blue)
  100.   gpu.setForeground(white)
  101.   gpu.fill(x,y,100,1," ")
  102.   gpu.set(x,y,texts)
  103. end
  104. ---draw Interface------
  105. function drawInterface()
  106. gpu.set(10,20,"Uwe Manfred")
  107. gpu.setBackground(0x4286F4)
  108. gpu.set(30,40,string.rep(" ",40))
  109.  
  110.  
  111.  
  112.  
  113.  
  114. end
  115. -----Main----
  116. drawBars()
  117. getReactor()
  118. while true do
  119. fuelControl()
  120. energyControl()
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement