Guest User

[Minecraft] CC: Mr.Coder's Turtle Control redone

a guest
Mar 23rd, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- List of actions
  2. -- button & function
  3. local action = {
  4.   r = turtle.refuel,
  5.   w = turtle.forward,
  6.   s = turtle.back,
  7.   a = turtle.turnLeft,
  8.   d = turtle.turnRight,
  9.   q = turtle.down,
  10.   e = turtle.up,
  11.   z = turtle.digDown,
  12.   x = turtle.dig,
  13.   c = turtle.digUp,
  14.   v = turtle.placeDown,
  15.   b = turtle.place,
  16.   n = turtle.placeUp,
  17. }
  18.  
  19. while true do
  20.   ev,key = os.pullEvent()
  21.  
  22.   -- Run the function assigned to the variable inside "action"
  23.   if ev == "char" then
  24.     action[key] then action[key]()
  25.  
  26.   -- Selection, supports slots 1 to 10
  27.   elseif ev == "key" then
  28.     if key >= 2 or key <= 11 then
  29.       turtle.select(key-1)
  30.     end
  31.   end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment