View difference between Paste ID: WmEPLE7m and HAZyb2qz
SHOW: | | - or go back to the newest paste.
1
local currentX = 1 --Saves the current X of the cursor
2
local currentY = 1 --Saves the current Y of the cursor
3
4
5
function drawCursor()
6
  term.clear() --Clears the screen
7
  term.setCursorPos(currentX, currentY)  --Draws a cursor at the current X/Y
8
  write(">")
9
end
10
11
12
while true do
13
  drawCursor()
14
  local e,key, char = os.pullEvent( "key" )
15-
  if e == "key" then
15+
  if e == "key" or key == 17 or key == 200 or key == 17 or key == 200 or key == 203 or key == 30 or key == 205 or key == 32 then
16
    if key == 17 or key == 200 then --up
17
          currentY = currentY -1
18-
    elseif key == 31 or key == 208 then --down
18+
    elseif key == 17 or key == 200 then --down
19
          currentY = currentY +1
20
    elseif key == 203 or key == 30 then --left
21
          currentX = currentX -1
22
    elseif key == 205 or key == 32 then --right
23
           currentX = currentX +1
24
    end
25
  elseif e == "char" then
26
    term.setCursorPos(currentX +1, currentY)
27
    write(char)
28
  end
29
end