Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- control.lua
- -- Program to control a turtle using W, A, S, D, Space, and Shift keys
- local function moveTurtle()
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.w then
- turtle.forward()
- elseif key == keys.a then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- elseif key == keys.s then
- turtle.back()
- elseif key == keys.d then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- elseif key == keys.space then
- turtle.up()
- elseif key == keys.leftShift then
- turtle.down()
- end
- end
- end
- -- Start the turtle control program
- print("Control the turtle with W, A, S, D, Space, and Shift keys.")
- moveTurtle()
Advertisement
Add Comment
Please, Sign In to add comment