Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("button") then
- shell.run("pastebin get LP2ZQ5dG button")
- end
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setBackgroundColor(colors.white)
- local w, h = term.getSize()
- for i = h - 4, h do
- term.setCursorPos(1, i)
- term.clearLine()
- end
- os.loadAPI("button")
- keys = {"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M"}
- local vKeys = {}
- local cKeys = {}
- local keyX = 1
- local keyY = h - 4
- for i, v in pairs(keys) do
- if v == "A" or v == "Z" then
- keyY = keyY + 2
- keyX = 1
- end
- vKeys[v] = button.Button:new(v, keyX, keyY, keyX, keyY, 8, 1, 8, 9)
- keyX = keyX + math.floor(w / 11)
- end
- Delete = button.Button:new("Delete", w - 5, h - 4, w, h - 4, 8, 1, 8, 9)
- Enter = button.Button:new("Enter", w - 4, h - 2, w, h - 2, 8, 1, 8, 9)
- Shift = button.Button:new("Shift", w - 4, h, w, h, 8, 1, 8, 9)
- local nextCap = false
- local xPos = 1
- local yPos = 1
- while true do
- Delete:display()
- Enter:display()
- Shift:display()
- for i, v in pairs(vKeys) do
- v:display()
- end
- button.getClick()
- for i, v in pairs(vKeys) do
- if v:check() then
- term.setCursorPos(xPos, yPos)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- if nextCap then
- term.write(i)
- else
- term.write(string.lower(i))
- end
- xPos = xPos + 1
- end
- end
- if xPos > w then
- xPos = 1
- yPos = yPos + 1
- end
- if Delete:check() then
- if xPos == 1 then
- xPos = w
- yPos = yPos - 1
- else
- xPos = xPos - 1
- end
- term.setCursorPos(xPos, yPos)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(" ")
- end
- if Enter:check() then
- yPos = yPos + 1
- xPos = 1
- end
- if Shift:check() then
- nextCap = true
- else
- nextCap = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement