Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Essential Functions API list
- -- integrate using os.loadAPI("file-name-here")
- function monitorSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "monitor" then
- test = name
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function bigReactorSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "BigReactors-Reactor" then
- print("reactor")
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function mekanismMachineSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "mekanism_machine" then
- test = name
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function modemSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "modem" then
- test = name
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function clear()
- mon = monitorSearch()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- --display text on computer's terminal screen
- function draw_text_term(x, y, text, text_color, bg_color)
- term.setTextColor(text_color)
- term.setBackgroundColor(bg_color)
- term.setCursorPos(x,y)
- write(text)
- end
- --display text text on monitor, "mon" peripheral
- function draw_text(x, y, text, text_color, bg_color)
- mon = monitorSearch()
- mon.setBackgroundColor(bg_color)
- mon.setTextColor(text_color)
- mon.setCursorPos(x,y)
- mon.write(text)
- end
- --draw line on computer terminal
- function draw_line(x, y, length, color)
- mon = monitorSearch()
- mon.setBackgroundColor(color)
- mon.setCursorPos(x,y)
- mon.write(string.rep(" ", length))
- end
- --draw line on computer terminal
- function draw_line_term(x, y, length, color)
- term.setBackgroundColor(color)
- term.setCursorPos(x,y)
- term.write(string.rep(" ", length))
- end
- -- Round Decimal Numbers
- function roundNumber(num, n)
- local mult = 10^(n or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- --create progress bar
- --draws two overlapping lines
- --background line of bg_color
- --main line of bar_color as a percentage of minVal/maxVal
- 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
- --create status bar
- --draws three overlapping lines
- --background line of bg_color
- function status_bar(x, y, length, minVal, medVal, maxVal, bar_color1, bar_color2, bg_color)
- draw_line(x, y, length, bg_color) --backgoround bar
- local barSize1 = math.floor((medVal/maxVal) * length)
- local barSize2 = math.floor((minVal/maxVal) * length)
- draw_line(x, y, barSize1, bar_color1) --progress so far
- draw_line(x, y, barSize2, bar_color2) --progress so far
- end
- --same as above but on the computer terminal
- function progress_bar_term(x, y, length, minVal, maxVal, bar_color, bg_color)
- draw_line_term(x, y, length, bg_color) --backgoround bar
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line_term(x, y, barSize, bar_color) --progress so far
- end
- --create button on monitor
- 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)
- end
- function heading(text)
- mon = monitorSearch()
- w, h = mon.getSize()
- mon.setCursorPos((w-string.len(text))/2+1, 1)
- mon.write(text)
- end
- function label(w, h, text, size, colour)
- mon = monitorSearch()
- mon.setCursorPos(w, h)
- mon.setTextScale(size)
- mon.setTextColor(colour)
- mon.write(text)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement