Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Starting robot test script")
- --init vars--
- local component = require("component")
- local sides = require("sides")
- local term = require("term")
- local robot = require("robot")
- local geo = component.geolyzer
- local inv = component.inventory_controller
- --util func--
- function itenInSlot (n)
- return inv.getStackInInternalSlot(n).name
- end
- function getDownName ()
- return geo.analyze(sides.down).name
- end
- --program vars--
- local i_for = itenInSlot(1)
- local i_bac = itenInSlot(2)
- local i_rot_r = itenInSlot(3)
- local i_rot_l = itenInSlot(4)
- local i_rot_180 = itenInSlot(5)
- local i_pause = itenInSlot(6)
- local i_break = itenInSlot(7)
- --functions--
- function f_until_stop()
- robot.forward()
- while true do
- b = getDownName()
- if b == i_bac or b == i_up or b == i_dow or b_== i_rot_r or b == i_rot_l or b == i_rot_180 or b == i_pause or b == i_break then
- break
- else
- robot.forward()
- end
- end
- end
- function b_until_stop()
- robot.backward()
- while true do
- b = getDownName()
- if b == i_for or b == i_up or b == i_dow or b_== i_rot_r or b == i_rot_l or b == i_rot_180 or b == i_pause or b == i_break then
- break
- else
- robot.back()
- end
- end
- end
- function main ()
- for i=1,7,1 do
- print(itenInSlot(i))
- end
- while true do
- b = getDownName()
- term.clear()
- print("Down block was: ", b)
- if b == i_for then
- f_until_stop()
- elseif b == i_bac then
- b_until_stop()
- elseif b == i_rot_r then
- robot.turnRight()
- f_until_stop()
- elseif b == i_rot_l then
- robot.turnLeft()
- f_until_stop()
- elseif b == i_rot_180 then
- robot.turnAround()
- f_until_stop()
- elseif b == i_pause then
- os.sleep(1)
- elseif b == i_break then break
- end
- end
- end
- main()
Add Comment
Please, Sign In to add comment