Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- KekApi (1.2)
- function centerText (text)
- local w, h = term.getSize()
- term.setCursorPos(math.floor(w / 2 - text:len() / 2 + .5), math.floor(h / 2 + .5))
- write(text)
- end
- function centerPrint (text)
- local textLen = string.len(text)
- local screenW,_ = term.getSize()
- local xCoords = tonumber(math.ceil((screenW / 2) - (textLen / 2)))
- local _,termY = term.getCursorPos()
- term.setCursorPos(xCoords,termY)
- print(text)
- return xCoords
- end
- function writeLine ()
- term.write("--------------------------------------------------")
- end
- function slowCenterPrint (text, time)
- local textLen = string.len(text)
- local screenW,_ = term.getSize()
- local xCoords = tonumber(math.ceil((screenW / 2) - (textLen / 2))) -- Da Ba Dee xD
- local _,termY = term.getCursorPos()
- term.setCursorPos(xCoords,termY)
- textutils.slowWrite(text, time)
- return xCoords
- end
- function drawMenu (tab1, x, y)
- if y == nil or x == nil then
- printError("podaj x i y dla menu!")
- end
- a = 0
- colorOld = term.getBackgroundColor()
- wbr = 1
- while true do
- w,h = term.getSize()
- if #tab1 < 10 then
- for i = 1, #tab1 do
- term.setCursorPos(x,y + i - 1)
- if i == wbr then
- term.setBackgroundColor(colors.gray)
- else
- term.setBackgroundColor(colorOld)
- end
- term.write(tab1[i])
- end
- elseif #tab1 > 10 or #tab1 == 10 then
- for i = 1, 10 do
- if i == wbr then
- term.setBackgroundColor(colors.gray)
- else
- term.setBackgroundColor(colorOld)
- end
- if wbr == 9 or wbr > 9 then
- i = wbr
- i = i - 1
- end
- term.setCursorPos(x,y + i - 1)
- term.clearLine()
- term.write(tab1[i])
- end
- end
- event, key = os.pullEvent("key")
- if key == keys.down and wbr < #tab1 then
- wbr = wbr + 1
- end
- if key == keys.up and wbr > 1 then
- wbr = wbr - 1
- end
- if key == keys.enter then
- break
- end
- end
- term.setBackgroundColor(colorOld)
- return wbr
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement