Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local currentX = 1 --Saves the current X of the cursor
- local currentY = 1 --Saves the current Y of the cursor
- function drawCursor()
- term.clear() --Clears the screen
- term.setCursorPos(currentX, currentY) --Draws a cursor at the current X/Y
- write(">")
- end
- while true do
- drawCursor()
- local e,key, char = os.pullEvent( "key" )
- if e == "key" then
- if key == 17 or key == 200 then --up
- currentY = currentY -1
- elseif key == 31 or key == 208 then --down
- currentY = currentY +1
- elseif key == 203 or key == 30 then --left
- currentX = currentX -1
- elseif key == 205 or key == 32 then --right
- currentX = currentX +1
- end
- elseif e == "char" then
- term.setCursorPos(currentX +1, currentY)
- write(char)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment