Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function periphalsearch(pname)
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == pname then
- return peripheral.wrap(name)
- end
- end
- return nil
- end
- monitor=periphalsearch("monitor")
- if not monitor then
- monitor=term
- end
- function clear()
- monitor.clear()
- end
- function getSize()
- return monitor.getSize()
- end
- function draw_text(x, y, text, text_color, bg_color)
- monitor.setBackgroundColor(bg_color)
- monitor.setTextColor(text_color)
- monitor.setCursorPos(x,y)
- monitor.write(text)
- end
- function draw_line(x, y, length, color)
- draw_text(x,y,string.rep(" ", length),color,color)
- end
- function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color)
- draw_line(x, y, length, bg_color) --backgoround bar
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line(x, y, barSize, bar_color) --progress so far
- end
- function button(x, y, length, text, txt_color, bg_color)
- draw_line(x, y, length, bg_color)
- draw_text((x+2), y, text, txt_color, bg_color)
- if clicked and mx>=x-1 and mx<=x+length+1 and my>=y-1 and my<=y+1 then
- return true
- end
- return false
- end
- function round(num,s)
- return math.floor((num*(10^s))+0.5)/(10^s)
- end
- clicked=false
- mx=0
- my=0
- function handletouch()
- clicked=false
- mx=0
- my=0
- local event, button, x, y = os.pullEvent("monitor_touch")
- clicked=true
- mx=x
- my=y
- end
- updatetime=1
- function timeout()
- sleep(updatetime)
- end
- function unit(amount)
- if amount > 1000000 then
- return round(amount/1000000,1).."M"
- elseif amount > 1000 then
- return round(amount/1000,1).."K"
- else
- return amount
- end
- end
- reactor=periphalsearch("fusionReactorLogicAdapter")
- function update()
- draw_text(3,2,"Reactor Control",colors.yellow,colors.black)
- tanks=(redstone.getAnalogInput("front")/15)
- tanks=math.min(tanks,reactor.getTritium().amount/1000)
- tanks=math.min(tanks,reactor.getDeuterium().amount/1000)
- inj=reactor.getInjectionRate()
- draw_text(3,3,"Tanks",colors.white,colors.black)
- progress_bar(3,4,20,tanks*100,100,colors.green, colors.white)
- draw_text(3,5,"Injection Rate",colors.white,colors.black)
- draw_text(3,6,inj,colors.white,colors.black)
- draw_text(3,7,"Generating",colors.white,colors.black)
- draw_text(3,8,unit(reactor.getPassiveGeneration(false)/2500).."RF/T",colors.white,colors.black)
- if tanks>0.7 then
- draw_text(3,9,"Injecting DT Fuel",colors.red,colors.black)
- redstone.setAnalogOutput("top",15)
- updatetime=0.05
- else
- draw_text(3,9,"Tank Level too low not injecting",colors.white,colors.black)
- redstone.setAnalogOutput("top",0)
- updatetime=1
- end
- end
- clear()
- while true do
- parallel.waitForAny(timeout,handletouch)
- update()
- end
Advertisement
Add Comment
Please, Sign In to add comment