Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load API
- os.loadAPI("tev")
- if not tev then
- error( "Turtle Event API not loaded!" )
- end
- --[[ === MAIN LOOP === ]]
- while true do
- local event, p1, p2, p3, p4 = re.pullEvent()
- if event == "turtle" then
- print( event..", "..tostring( p1 )..", "..tostring( p2 )..", "..tostring( p3 )..", "..tostring( p4 ) )
- end
- -- Moving
- if event == "key" and p1 == 200 then tev.forward() end -- UP
- if event == "key" and p1 == 208 then tev.back() end -- DOWN
- if event == "key" and p1 == 57 then tev.up() end -- SPACE
- if event == "key" and p1 == 42 then tev.down() end -- LSHIFT
- if event == "key" and p1 == 203 then tev.turnLeft() end -- LEFT
- if event == "key" and p1 == 205 then tev.turnRight() end -- RIGHT
- -- Placing
- if event == "key" and p1 == 71 then tev.placeUp() end -- NUMPAD 7
- if event == "key" and p1 == 75 then tev.place() end -- NUMPAD 4
- if event == "key" and p1 == 79 then tev.placeDown() end -- NUMPAD 1
- -- Detecting
- if event == "key" and p1 == 72 then tev.detectUp() end -- NUMPAD 8
- if event == "key" and p1 == 76 then tev.detect() end -- NUMPAD 5
- if event == "key" and p1 == 80 then tev.detectDown() end -- NUMPAD 2
- -- Digging
- if event == "key" and p1 == 73 then tev.digUp() end -- NUMPAD 9
- if event == "key" and p1 == 77 then tev.dig() end -- NUMPAD 6
- if event == "key" and p1 == 81 then tev.digDown() end -- NUMPAD 3
- -- Comparing
- if event == "char" and string.lower( p1 ) == "q" then tev.compareUp() end
- if event == "char" and string.lower( p1 ) == "a" then tev.compare() end
- if event == "char" and string.lower( p1 ) == "y" then tev.compareDown() end
- -- Dropping
- if event == "char" and string.lower( p1 ) == "g" then tev.drop() end
- if event == "char" and string.lower( p1 ) == "b" then tev.drop(5) end
- -- Selecting
- if event == "char" and string.lower( p1 ) == "x" then tev.select(1) end
- if event == "char" and string.lower( p1 ) == "c" then tev.select(2) end
- -- Stopping program
- if event == "char" and string.lower( p1 ) == "e" then break end
- end
- -- Cleanup
- os.unloadAPI( tev )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement