David_Turtle

Turtle "eZ-Shell"

Nov 7th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.40 KB | None | 0 0
  1. -- Dieses Programm ist fuer eine vereinfachte Benutzung der Turtle aus Computercraft
  2. function vor()
  3.     if turtle.detect() then
  4.         print("")
  5.         print("Fehler : Turtle kann sich nicht bewegen")
  6.     else
  7.         if turtle.getFuelLevel() == 0 then
  8.             print("")
  9.             print("Fehler : Kein Treibstoff")
  10.         else
  11.                 turtle.forward()
  12.                 print("Vorwaerts")
  13.         end
  14.     end
  15. end
  16. function zurueck()
  17.         if turtle.getFuelLevel() == 0 then
  18.         print("")
  19.         print("Fehler : Kein Treibstoff")
  20.     else
  21.             turtle.back()
  22.             print("Zurueck")
  23.     end
  24. end
  25. function links()
  26.     if turtle.getFuelLevel() == 0 then
  27.         print("")
  28.         print("Fehler : Kein Treibstoff")
  29.     else
  30.         turtle.turnLeft()
  31.         if turtle.detect() then
  32.             print("")
  33.             print("Fehler : Turtle kann sich nicht bewegen")
  34.         else
  35.                 turtle.forward()
  36.                 print("Links")
  37.         end
  38.             turtle.turnRight()
  39.     end
  40.        
  41. end
  42. function rechts()
  43.     if turtle.getFuelLevel() == 0 then
  44.         print("")
  45.         print("Fehler : Kein Treibstoff")
  46.     else
  47.             turtle.turnRight()
  48.         if turtle.detect() then
  49.             print("")
  50.             print("Fehler : Turtle kann sich nicht bewegen")
  51.         else
  52.                 turtle.forward()
  53.                 print("Rechts")
  54.         end
  55.         turtle.turnLeft()
  56.     end
  57.        
  58. end
  59. function hoch()
  60.     if turtle.detectUp() then
  61.         print("")
  62.         print("Fehler : Turtle kann sich nicht bewegen")
  63.     else
  64.         if turtle.getFuelLevel() == 0 then
  65.             print("")
  66.             print("Fehler : Kein Treibstoff")
  67.         else
  68.                 turtle.up()
  69.                 print("Hoch")
  70.         end
  71.         end
  72. end
  73. function runter()
  74.     if turtle.detectDown() then
  75.         print("")
  76.         print("Fehler: Turtle kann sich nicht bewegen")
  77.     else
  78.         if turtle.getFuelLevel() == 0 then
  79.             print("")
  80.             print("Fehler : Kein Treibstoff")
  81.         else
  82.                 turtle.down()
  83.                 print("Runter")
  84.         end
  85.         end
  86. end
  87. function rechtsDrehen()
  88.         turtle.turnRight()
  89.         print("Nach Rechts drehen")
  90. end
  91. function linksDrehen()
  92.         turtle.turnLeft()
  93.         print("Nach Links drehen")
  94. end
  95. function grab()
  96.     if turtle.detect() then
  97.             turtle.dig()
  98.             print("Vorne Graben")
  99.     else
  100.         print("")
  101.         print("Fehler : Kein Block gefunden")
  102.     end
  103. end
  104. function grabRunter()
  105.         if turtle.detectDown() then
  106.             turtle.digDown()
  107.             print("Runter Graben")
  108.     else
  109.         print("")
  110.         print("Fehler : Kein Block gefunden")
  111.     end
  112. end
  113. function grabHoch()
  114.         if turtle.detectUp() then
  115.             turtle.digUp()
  116.             print("Hoch Graben")
  117.     else
  118.         print("")
  119.         print("Fehler : Kein Block gefunden")
  120.     end
  121. end
  122. function fuel()
  123.     print("")
  124.         print("Treibstoff: "..turtle.getFuelLevel())
  125. end
  126. function refuel()
  127.         turtle.refuel()
  128.     print("")
  129.     print("Treibstoff: "..turtle.getFuelLevel())
  130. end
  131. function exit()
  132.         term.clear()
  133.         term.setCursorPos(1,1)
  134.         print("Programm beendet")
  135.     print("Computer wird in kuerze neustarten")
  136.     os.sleep(1)
  137.         os.reboot()
  138. end
  139. function clear()
  140.     term.clear()
  141.     term.setCursorPos(0,0)
  142. end
  143. function version()
  144.     print("")
  145.     print("eZ-Shell v.1.5")
  146.     print("von David_10101")
  147. end
  148. function select()
  149.     print("")
  150.     print("Welchen Slot auswaehlen?")
  151.     print("")
  152.     local slot = read()
  153.     slot = tonumber(slot)
  154.     if slot < 1 then
  155.         print("")
  156.         print("Fehler : Slot nicht real")
  157.     elseif slot > 16 then
  158.         print("")
  159.         print("Fehler : Slot nicht real")
  160.     else
  161.         turtle.select(slot)
  162.     end
  163.     print("")
  164. end
  165. function help()
  166.         term.clear()
  167.         term.setCursorPos(1,1)
  168.     term.write("Verfuegbare Kommandos")
  169.     print("")
  170.     term.write("Bewegen:")
  171.     print("")
  172.     term.write("vor, zurueck, links, rechts, drehLinks,")
  173.     print("drehRechts")
  174.     print("")
  175.     term.write("Graben:")
  176.     print("")
  177.     term.write("grab, grabHoch, grabRunter")
  178.     print("")
  179.     print("")
  180.     term.write("Treibstoff:")
  181.     print("")
  182.     term.write("fuel, refuel")
  183.     print("")
  184.     print("")
  185.     term.write("Shell-Kommandos:")
  186.     print("")
  187.     term.write("exit, clear, version, ab, select")
  188. end
  189. function abkuerzung()
  190.     term.clear()
  191.     term.setCursorPos(1,1)
  192.     term.write("Bewegen:")
  193.     print("")
  194.     term.write("v, z, r, h, l, re, dl, dr")
  195.     print("")
  196.     term.write("Graben:")
  197.     print("")
  198.     term.write("g, gh, grr")
  199.     print("")
  200.     print("")
  201.     term.write("Treibstoff:")
  202.     print("")
  203.     term.write("f, rf")
  204.     print("")
  205.     print("")
  206.     term.write("Shell-Kommandos:")
  207.     print("")
  208.     term.write("e, c, ve, ab, s")
  209. end
  210.  
  211. term.clear()
  212. term.setCursorPos(1,1)
  213. term.write("eZ-Shell v.1.5")
  214. sleep(0.5)
  215. while true do
  216.     print("")
  217.         command = read()
  218.         if command == "vor" then
  219.                 vor()
  220.     elseif command == "v" then
  221.         vor()
  222.         elseif command == "zurueck" then
  223.                 zurueck()
  224.     elseif command == "z" then
  225.         zurueck()
  226.         elseif command == "links" then
  227.                 links()
  228.     elseif command == "l" then
  229.         links()
  230.         elseif command == "rechts" then
  231.                 rechts()
  232.     elseif command == "re" then
  233.         rechts()
  234.         elseif command == "hoch" then
  235.         hoch()
  236.     elseif command == "h" then
  237.                 hoch()
  238.         elseif command == "runter" then
  239.                 runter()
  240.     elseif command == "r" then
  241.         runter()
  242.         elseif command == "drehRechts" then
  243.                 rechtsDrehen()
  244.     elseif command == "dr" then
  245.         rechtsDrehen()
  246.         elseif command == "drehLinks" then
  247.                 linksDrehen()
  248.     elseif command == "dl" then
  249.         linksDrehen()
  250.         elseif command == "grab" then
  251.                 grab()
  252.     elseif command == "g" then
  253.         grab()
  254.         elseif command == "grabHoch" then
  255.                 grabHoch()
  256.     elseif command == "gh" then
  257.         grabHoch()
  258.         elseif command == "grabRunter" then
  259.                 grabRunter()
  260.     elseif command == "gr" then
  261.         grabRunter()
  262.         elseif command == "fuel" then
  263.                 fuel()
  264.     elseif command == "f" then
  265.         fuel()
  266.     elseif command == "rf" then
  267.         refuel()
  268.         elseif command == "refuel" then
  269.                 refuel()
  270.         elseif command == "exit" then
  271.                 exit()
  272.         elseif command == "help" then
  273.                 help()
  274.     elseif command == "clear" then
  275.         clear()
  276.     elseif command == "c" then
  277.         clear()
  278.     elseif command == "version" then
  279.         version()
  280.     elseif command == "ve" then
  281.         version()
  282.     elseif command == "ab" then
  283.         abkuerzung()
  284.     elseif command == "e" then
  285.         exit()
  286.     elseif command == "select" then
  287.         select()
  288.     elseif command == "s" then
  289.         select()
  290.         else
  291.                 print("Fehler : Unbekannter Kommando")
  292.         print("")
  293.         print("Kommandoliste mit help")
  294.         print("Abkuerzungen mit ab")
  295.         print("")
  296.                 os.sleep(1)
  297.         end
  298. end
Advertisement
Add Comment
Please, Sign In to add comment