Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local robot = require("robot")
- local args = {...}
- local levelCurrent = 1
- platforms = args[1]
- levels = args[2]
- if platforms==nil or levels== nil then
- print("ERROR, MISSING PLATFORMS OR HEIGHT VARS")
- os.exit()
- end
- function levelUp()
- if select(2,robot.detectUp()) == "solid" then
- print("MAXIMUM HEIGHT REACHED, ABORTING")
- else
- u(4)
- levelCurrent = levelCurrent + 1
- print("Current level is: " .. levelCurrent)
- end
- end
- function levelDown()
- if select(2,robot.detectDown()) == "solid" then
- print("MINIMUM HEIGHT REACHED, ABORTING")
- else
- d(4)
- levelCurrent = levelCurrent - 1
- print("Current level is: " .. levelCurrent)
- end
- end
- function u(x)
- for i=tonumber(x),1,-1 do
- repeat
- robot.swingUp()
- until(robot.up())
- end
- end
- function d(x)
- for i=tonumber(x),1,-1 do
- repeat
- robot.swingDown()
- until(robot.down())
- end
- end
- function f(x)
- for i=tonumber(x),1,-1 do
- repeat
- robot.swing()
- until(robot.forward())
- end
- end
- function b(x)
- for i=tonumber(x),1,-1 do
- local count = -1
- repeat
- count = count + 1
- if count>0 then
- l(2)
- repeat
- robot.swing()
- until(not robot.detect())
- r(2)
- end
- until(robot.back())
- end
- end
- function r(x)
- for i=tonumber(x),1,-1 do
- robot.turnRight()
- end
- end
- function l(x)
- for i=tonumber(x),1,-1 do
- robot.turnLeft()
- end
- end
- function clearPlatform()
- r(1)
- f(2)
- l(1)
- f(5)
- l(1)
- f(4)
- l(1)
- f(4)
- l(1)
- f(3)
- l(1)
- f(3)
- l(1)
- f(2)
- l(1)
- f(2)
- l(1)
- f(1)
- end
- function clearLevel()
- local effective = 0
- for i=tonumber(platforms),1,-1 do
- effective = effective + 1
- f(2)
- clearPlatform()
- l(1)
- if(i==1) then
- f(3)
- if(select(2,robot.detect())=="solid") then
- print("LAST PLATFORM, ABORTING NEXT ITERATIONS")
- break
- end
- else
- f(4)
- end
- end
- r(2)
- f(((effective*5) + (effective*3))-1)
- r(2)
- end
- function dropStuff()
- local perc = 0
- local tot = 100/robot.inventorySize()
- for i=robot.inventorySize(),1,-1 do
- robot.select(i)
- robot.dropDown()
- perc = perc + tot
- term.clearLine()
- io.write("DROPPING ITEMS: " .. math.ceil(perc) .. "%")
- end
- print(" ")
- end
- while true do
- for i=1,tonumber(levels),1 do
- print("Now going for level: " .. i )
- print("Current level is: " .. levelCurrent)
- if(not(levelCurrent == i)) then
- repeat
- levelUp()
- until(tonumber(levelCurrent) == i)
- end
- clearLevel()
- if(not(levelCurrent == 1)) then
- repeat
- levelDown()
- until(levelCurrent==1)
- end
- dropStuff()
- end
- os.sleep(300)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement