Spoiler
local mon = peripheral.wrap("right")
local dmon = peripheral.wrap("monitor_4")
local i, input, shift, touch = 0, "string", "False", {}
local ln1, ln2, ln3, ln4 = "string", "string", "string", "string"
dmon.setTextScale(3)
mon.setTextScale(4)
mon.setBackgroundColor(colors.blue)
mon.clear()
while true do
--Check shift
if shift == "True" then
ln1, ln2, ln3, ln4 = "!@#$%^&*() |DELETE|", " QWERTYUIOP", " ASDFGHJKL |ENTER|", " ZXCVBNM |SHIFT|"
shift = "False"
elseif shift == "False" then
ln1, ln2, ln3, ln4 = "1234567890 |delete|", " qwertyuiop", " asdfghjkl |enter|", " zxcvbnm |shift|"
end
--Render
mon.clear()
mon.setCursorPos(1, 1) mon.write(ln1)
mon.setCursorPos(1, 2) mon.write(ln2)
mon.setCursorPos(1, 3) mon.write(ln3)
mon.setCursorPos(1, 4) mon.write(ln4)
i = #touch + 1 --#Changed this from "i = i + 1" and it works now...
local event, side, x, y = os.pullEvent("monitor_touch")
if y == 1 and x <= 10 then
touch[i] = string.sub(ln1, x, x)
elseif y == 2 and x <= 11 then
touch[i] = string.sub(ln2, x, x)
elseif y == 3 and x <= 11 then
touch[i] = string.sub(ln3, x, x)
elseif y == 4 and x <= 10 then
touch[i] = string.sub(ln4, x, x)
elseif y == 1 and x >= 13 and x <= 20 then --Delete Button
i = #touch - 1
touch[#touch] = nil
elseif y == 3 and x >= 14 and x <= 20 then --Enter Button
input = table.concat(touch)
if input == "Pa55w0rd" then --commands here
rednet.open("left")
rednet.broadcast("Success!")
rednet.close("left")
end
touch, i = {}, 0
elseif y == 4 and x >= 14 and x <= 20 then --Shift Button
if shift == "True" then
shift = "False"
else
shift = "True"
end
end
dmon.clear()
dmon.setCursorPos(1, 2)
if table.concat(touch) then
dmon.write(table.concat(touch))
end
sleep(0.1)
end
Edit2: forgot to say, this program should work as a keyboard now :P/>