Advertisement
King0fGamesYami

Monkey

Apr 18th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1. local mon = peripheral.wrap("right")
  2. local dmon = peripheral.wrap("monitor_4")
  3. local i, input, shift, touch = 0, "string", false, {}
  4. local ln1, ln2, ln3, ln4 = "string", "string", "string", "string"
  5.  
  6. dmon.setTextScale(3)
  7. mon.setTextScale(4)
  8. mon.setBackgroundColor(colors.blue)
  9. mon.clear()
  10.  
  11. while true do
  12.  --Check shift
  13.  if shift then
  14.   ln1, ln2, ln3, ln4 = "!@#$%^&*()  |DELETE|", " QWERTYUIOP", "  ASDFGHJKL  |ENTER|", "   ZXCVBNM   |SHIFT|"
  15.   shift = false
  16.  else
  17.   ln1, ln2, ln3, ln4 = "1234567890  |delete|", " qwertyuiop", "  asdfghjkl  |enter|", "   zxcvbnm   |shift|"
  18.  end
  19.  --Render
  20.  mon.clear()
  21.  mon.setCursorPos(1, 1) mon.write(ln1)
  22.  mon.setCursorPos(1, 2) mon.write(ln2)
  23.  mon.setCursorPos(1, 3) mon.write(ln3)
  24.  mon.setCursorPos(1, 4) mon.write(ln4)
  25.  
  26.   i = #touch + 1 --#Changed this from "i = i + 1" and it works now...
  27.   local event, side, x, y = os.pullEvent("monitor_touch")
  28.   if y == 1 and x <= 10 then
  29.    touch[i] = string.sub(ln1, x, x)
  30.   elseif y == 2 and x <= 11 then
  31.    touch[i] = string.sub(ln2, x, x)
  32.   elseif y == 3 and x <= 11 then
  33.    touch[i] = string.sub(ln3, x, x)
  34.   elseif y == 4 and x <= 10 then
  35.    touch[i] = string.sub(ln4, x, x)
  36.   elseif y == 1 and x >= 13 and x <= 20 then --Delete Button
  37.    i = #touch - 1
  38.    touch[#touch] = nil
  39.   elseif y == 3 and x >= 14 and x <= 20 then  --Enter Button
  40.    input = table.concat(touch)
  41.         if input == "Pa55w0rd" then --commands here
  42.          rednet.open("left")
  43.          rednet.broadcast("Success!")
  44.          rednet.close("left")
  45.         end
  46.    touch, i = {}, 0
  47.   elseif y == 4 and x >= 14 and x <= 20 then --Shift Button
  48.    if shift then
  49.      shift = false
  50.    else
  51.      shift = true
  52.    end
  53.   end
  54.   dmon.clear()
  55.   dmon.setCursorPos(1, 2)
  56.   if table.concat(touch) then
  57.    dmon.write(table.concat(touch))
  58.   end
  59.   sleep(0.01)
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement