Advertisement
Guest User

testkey.lua

a guest
Jul 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. local function inspectBlock()
  2.  local success,blk = turtle.inspect()
  3.  if(success) then
  4.      return blk.name
  5.  else
  6.      return "none/air"
  7.  end
  8. end
  9.  
  10. while true do
  11.     press, key = os.pullEvent()
  12.    
  13.     if(press == "key_up") then
  14.    
  15.     if(press == "key_up" and key == keys.q) then
  16.        break
  17.    
  18.     elseif(key == keys.space) then
  19.         print("Space")
  20.         turtle.dig()
  21.         print(inspectBlock())
  22.                
  23.     elseif(key == keys.a) then
  24.         print("Left")
  25.         turtle.turnLeft()
  26.         print(inspectBlock())
  27.    
  28.     elseif(key == keys.d) then
  29.         print("Right")
  30.         turtle.turnRight()
  31.         print(inspectBlock())
  32.        
  33.     elseif(key == keys.s) then
  34.         print("Back")
  35.         turtle.back()
  36.         print(inspectBlock())
  37.        
  38.     elseif(key == keys.w) then
  39.         print("Forward")
  40.         turtle.forward()
  41.         print(inspectBlock())
  42.  
  43.     elseif(key == keys.e) then
  44.         print("Up")
  45.         turtle.up()    
  46.         print(inspectBlock())
  47.  
  48.     elseif(key == keys.x) then
  49.         print("Down")
  50.         turtle.down()
  51.         print(inspectBlock())
  52.        
  53.     elseif(key == keys.z) then
  54.         print(inspectBlock())
  55.  
  56.     elseif(key == keys.f) then
  57.         print("Fuel: "..turtle.getFuelLevel())
  58.  
  59.     else
  60.         if(press ~= nil and key ~= nil) then
  61.             print("press: "..press.."key: "..key)
  62.         end
  63.     end
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement