Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ejectall()
- disk.eject("top")
- disk.eject("bottom")
- disk.eject("right")
- disk.eject("left")
- disk.eject("front")
- disk.eject("back")
- end
- function menu(...)
- arg = {...}
- headline = #arg
- if arg[headline] == nil then arg[headline] = " " end
- print(arg[headline])
- print(" ")
- x = #arg - 1
- y = 2
- print("["..arg[1].."]")
- while true do
- if y > x then
- break
- end
- print(" "..arg[y].." ")
- y = y + 1
- end
- mPos = 1
- while true do
- event, key = os.pullEvent("key")
- if key == 208 then
- if mPos < x then
- mPos = mPos + 1
- else
- mPos = 1
- end
- end
- if key == 200 then
- if mPos > 1 then
- mPos = mPos - 1
- else
- mPos = x
- end
- end
- if key == 28 then
- break
- end
- y = 1
- term.clear()
- term.setCursorPos(1,1)
- print(arg[headline])
- print(" ")
- while true do
- if y > x then
- break
- end
- if mPos == y then
- print("["..arg[y].."]")
- else
- print(" "..arg[y].." ")
- end
- y = y + 1
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- return mPos
- end
- function percent(...)
- local tArgs = {...}
- x,y = term.getSize()
- term.clear()
- term.setCursorPos(1,1)
- x = x / 4
- y = y / 2
- term.setCursorPos(y,x)
- local p = tArgs[1] * 100 / tArgs[2]
- write(p)
- write(" % step "..tArgs[1].." of "..tArgs[2])
- y = y + 1
- x = x + 1
- term.setCursorPos(y,x)
- if p > 10 or p == 10 then pb = 1 end if p > 20 or p == 20 then pb = 2 end if p > 30 or p == 30 then pb = 3 end if p > 40 or p == 40 then pb = 4 end if p > 50 or p == 50 then pb = 5 end if p > 60 or p == 60 then pb = 6 end if p > 70 or p == 70 then pb = 7 end if p > 80 or p == 80 then pb = 8 end if p > 90 or p == 90 then pb = 9 end if p > 100 or p == 100 then pb = 10 end
- if pb == nil then pb = 0 end
- write("[")
- pbx = 1
- while true do
- if pbx > pb then break end
- write("#")
- pbx = pbx + 1
- end
- y = y + 10
- term.setCursorPos(y,x)
- write("]")
- x,y=term.getSize()
- y = y - 1
- term.setCursorPos(1,y)
- if tArgs[3] == nil then
- print("percent monitor is a part of the cAPI by timosmods.yolasite.com")
- end
- term.setCursorPos(1,1)
- end
- function createButton(...)
- local tArgs = {...}
- xPos = tArgs[1]
- yPos = tArgs[2]
- Text = tArgs[3]
- Xcolor = tArgs[4]
- Tcolor = tArgs[5]
- Bcolor = tArgs[6]
- side = tArgs[7]
- if side ~= "intern" then
- m = peripheral.wrap(side)
- else m = term
- end
- m.setBackgroundColor(Bcolor)
- m.setCursorPos(xPos,yPos)
- m.setBackgroundColor(Xcolor)
- m.write("X")
- m.setBackgroundColor(Bcolor)
- m.write(" ")
- m.setBackgroundColor(Tcolor)
- m.write(Text)
- m.setBackgroundColor(Bcolor)
- end
- function runButtonIntern(...)
- local tArgs = {...}
- event,side,xPos,yPos = os.pullEvent("mouse_click")
- b = 1
- x = 1
- while true do
- y = x + 1
- if tArgs[y] == nil then return false end
- if xPos == tArgs[x] then
- if yPos == tArgs[y] then
- return b
- end
- end
- b = b + 1
- x = x + 2
- end
- end
- function runButton(...)
- local tArgs = {...}
- event,button,xPos,yPos = os.pullEvent("monitor_touch")
- b = 1
- x = 1
- while true do
- y = x + 1
- if tArgs[y] == nil then return false end
- if xPos == tArgs[x] then
- if yPos == tArgs[y] then
- return b
- end
- end
- b = b + 1
- x = x + 2
- end
- end
- function eventTimer(...)
- local tArgs = {...}
- if tArgs[1] ~= nil then os.startTimer(tArgs[1]) end
- Tevent,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 = os.pullEvent(tArgs[2])
- if Tevent[1] == "timer" then Tevent = "timeout" end
- return Tevent,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10
- end
Advertisement
Add Comment
Please, Sign In to add comment