Advertisement
Bendix

Raum_Ausheben_openComputers

Jun 16th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. -- noch ergänzen:
  2. -- benötigte Komponenten?? inventory controller, generator, chunkloader, ...?
  3. local component = require("component")
  4. local computer = require("computer")
  5. local robot = require("robot")
  6. local shell = require("shell")
  7. local sides = require("sides")
  8.  
  9. local navi = component.navigation
  10. local r=component.robot
  11. local c=component.computer
  12. local weit=100
  13. local breit=100
  14.  
  15. local x, y, z, f = 0, 0, 0, 0
  16. --x
  17. --y
  18. --z
  19. --f =facing?
  20.  
  21. local function tanken()
  22.    os.execute("tanken")
  23. end
  24. local function waffe()
  25.    if ((robot.durability()*100) < 50) then
  26.       while (robot.durability()*100) <90 do
  27.          print("Waffe bei",robot.durability()*100)
  28.          tanken()
  29.          os.sleep(5)
  30.       end
  31.    end
  32. end
  33.  
  34. local function turnRight()
  35.   robot.turnRight()
  36.   f = (f + 1) % 4
  37. end
  38. local function turnLeft()
  39.   robot.turnLeft()
  40.   f = (f + 1) % 4
  41. end
  42. local function dig()
  43.    if (robot.detect()) then
  44.       robot.swing()
  45.    end
  46. end
  47. local function forward()
  48.    while not robot.forward() do
  49.       os.sleep(0.5)
  50.       dig()
  51.       if (robot.detect() ) then
  52.          os.sleep(1)
  53.          dig()
  54.       end
  55.    end
  56. end
  57.  
  58.  
  59. local function back()
  60.    robot.back()
  61. end
  62.  
  63.  
  64.  
  65. local function digUp()
  66.    if (robot.detectUp()) then
  67.       robot.swingUp()
  68.    end
  69. end
  70. local function digDown()
  71.    if (robot.detectDown()) then
  72.       robot.swingDown()
  73.    end  
  74. end
  75. local richtung=0
  76. for y=1,breit do
  77. print("bin schon ", y," von",breit,"gegangen")
  78.    waffe()
  79.    richtung = y%2
  80.    back =y
  81.    for x=1,weit do
  82.       tanken()
  83.       dig()
  84.       digUp()
  85.       if(x==1 and y==1)then
  86.       else
  87.          digDown()
  88.       end
  89.       forward()
  90.    end
  91.    if (richtung == 0) then
  92.       turnLeft()
  93.       dig()
  94.       digUp()
  95.       --digDown()
  96.       forward()  
  97.       turnLeft()
  98.       dig()
  99.       digUp()
  100.       digDown()
  101.                turnLeft()
  102.                for z=1,back do
  103.                   forward()
  104.                   if (z==back) then
  105.                   else
  106.                   digDown()
  107.                   end
  108.                  
  109.                
  110.                end
  111.                for x=9,robot.inventorySize() do
  112.                robot.select(x)
  113.                robot.drop()
  114.                end
  115.                robot.select(1)
  116.                turnRight()
  117.                os.sleep(15)
  118.                turnRight()
  119.                for z=1,back do
  120.                   forward()
  121.                end
  122.                turnLeft()
  123.  
  124.    else
  125.       turnRight()
  126.       dig()
  127.       digUp()
  128.       digDown()
  129.       forward()  
  130.       turnRight()
  131.       dig()
  132.       digUp()
  133.       digDown()
  134.  
  135.    end
  136.  
  137. end
  138.  
  139. turnRight()
  140. turnRight()
  141. turnRight()
  142. for x=1,breit do
  143.    forward()
  144. end
  145. turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement