Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- For Clearing Space to the left and to the left, 3 dimenstions
- -- @BertMoTron
- -- place the robot facing forward
- -- number of steps
- local nOne = 0
- local nTwo = 0
- local nThr = 0
- local nTwoLess = 0
- -- check for arguments
- args = {...}
- if args[1] ~= nil then
- -- make sure it's a number
- local oneArg = tonumber(args[1])
- if oneArg then
- nOne = oneArg
- end
- end
- if args[2] ~= nil then
- -- make sure it's a number
- local twoArg = tonumber(args[2])
- if twoArg then
- nTwo = twoArg
- nTwoLess = (twoArg - 1)
- end
- end
- if args[3] ~= nil then
- local thrArg = tonumber(args[3])
- if thrArg then
- nThr = thrArg
- end
- end
- local robot = require("robot")
- local computer = require("computer")
- local FUEL_SLOT=1
- local FILL_SLOT=16
- function rS()
- os.sleep(0.3)
- end
- function rF()
- return robot.forward()
- end
- function rB()
- return robot.back()
- end
- function rL()
- return robot.turnLeft()
- end
- function rR()
- return robot.turnRight()
- end
- function rUp()
- return robot.up()
- end
- function rDown()
- return robot.down()
- end
- function errorM()
- print("ERROR!!! ERROR!!!! WILL ROBINSON!!!")
- end
- function tF()
- if rF() == false then
- return errorM()
- end
- print("move Forward!!!!!!!!!!")
- end
- function tB()
- if rB() == false then
- return errorM()
- end
- end
- function tL()
- if rL() == false then
- return errorM()
- end
- end
- function tR()
- if rR() == false then
- return errorM()
- end
- end
- function tUp()
- if rUp() == false then
- return errorM()
- end
- end
- function tDown()
- if rDown() == false then
- return errorM()
- end
- end
- -- Refuel
- function rFuel()
- print("Fuelvl: " ..computer.energy())
- if computer.energy() <= 500 then
- computer.shutdown()
- elseif computer.energy() <= 10000 and robot.space(FUEL_SLOT) < 63 then
- os.execute("fuel.lua " ..FUEL_SLOT.. " 1")
- print("Fuelvl: " ..computer.energy())
- rS()
- end
- end
- function dirDig(direction)
- if direction == -1 then
- return robot.swingDown()
- elseif direction == 1 then
- return robot.swingUp()
- else
- return robot.swing()
- end
- end
- function dirDtect(direction)
- if direction == -1 then
- return robot.detectDown()
- elseif direction == 1 then
- return robot.detectUp()
- else
- return robot.detect()
- end
- end
- -- are you sand/gdetectravel or is there sand/gravel above you
- function tDig(direction)
- local d = 0
- if dirDtect(direction) == true then
- while dirDtect(direction) and d < 16 do
- d = d + 1
- print("tDig" ..d)
- dirDig(direction)
- end
- end
- end
- function chop()
- rFuel()
- tDig(0)
- tDig(-1)
- tDig(1)
- end
- -- startUp()
- -- rFurnance
- function cutLine()
- if nOne > 1 then
- for i=2, nOne do
- rS()
- print("cutLine" ..i)
- rS()
- chop()
- rS()
- tF()
- rS()
- end
- end
- end
- function cutLineLeft()
- for i=1, nTwo do
- rS()
- cutLine()
- rS()
- -- turn left, right or not to turn
- if i <= nTwoLess and i % 2 == 0 then
- tR()
- chop()
- tF()
- tR()
- elseif i <= nTwoLess and i % 2 == 1 then
- tL()
- chop()
- tF()
- tL()
- end
- end
- if nTwo % 2 == 1 then
- tL()
- tL()
- cutLine()
- print("cutLineLeft: " ..nTwo)
- end
- end
- function reCut()
- if nTwoLess >= 1 then
- for i=1, nTwoLess do
- rS()
- print("going back" ..nTwo.. ".")
- rS()
- chop()
- rS()
- tF()
- rS()
- end
- end
- end
- --main
- function full_Cut_Left()
- for i=1, nThr do
- cutLineLeft()
- tL()
- rS()
- reCut()
- rS()
- tL()
- tDig(1)
- if i <= (nThr - 1) then
- rS()
- rUp()
- rS()
- tDig(1)
- rS()
- rUp()
- rS()
- tDig(1)
- rS()
- rUp()
- rS()
- end
- end
- if nThr >= 2 then
- for i=2, nThr do
- rS()
- tDig(-1)
- rS()
- rDown()
- rS()
- tDig(-1)
- rS()
- rDown()
- rS()
- tDig(-1)
- rS()
- rDown()
- rS()
- end
- end
- end
- --Start up
- full_Cut_Left()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement