Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- A MrReps's program for automation of 3*3*3 compact Machines' structs in compact claustrophobia for opencomputer robot with inventory controller and angel upgrade
- -- Probably working on all other pack
- -- Place the robot on the front of the field
- -- Place three caches on each side of the robot (exept in front)
- -- Place a charger on the bottom (dont forget to put a redstone signals on it)
- -- Place a collector or something to get the crafted stuff
- -- You can use it freely ^^
- local component = require("component")
- local sides = require("sides")
- local robot = require("robot")
- local computer = require("computer")
- local event = require("event")
- local tty = require("tty")
- local craft_number
- local input
- local tempo
- local checking
- function IsNumber(var)
- if type(var) == "number" then
- return true
- else
- return false
- end
- end
- function InputNumber()
- local entree
- local redo
- repeat
- entree = tonumber(io.read())
- if IsNumber(entree) then
- redo = true
- else
- redo = false
- print("Not a valid number retry")
- end
- until(redo)
- return entree
- end
- function Stop()
- tty.clear()
- print("That was nice to work with you :)")
- print("computer will stop in 5 second!")
- os.sleep(5)
- tty.clear()
- computer.shutdown()
- end
- function Wall()
- local continues = false
- local count = 0
- robot.select(1)
- tty.clear()
- print("You choose to make some wall !")
- print("How many craft do you want to do ?")
- craft_number = InputNumber()
- tty.clear()
- io.write("You will need:\n")
- io.write(craft_number," Block of iron\n")
- io.write((2*craft_number)," Redstone powder\n")
- io.write("When you are facing the field:\n")
- io.write("The robot will check that there is indeed\nthe material.\n")
- io.write(" Inventory on the right need redstone\n")
- io.write(" Inventory on the back need Iron Block\n")
- io.write("Don't forget to place something to collect the\nloot !\n")
- io.write("Do you want to continues ?\n")
- io.write("Press any key to continues\n")
- event.pull("key_down")
- --check
- robot.turnRight()
- checking = component.inventory_controller.getStackInSlot(sides.front,1)
- if checking.name == "minecraft:redstone" then
- if checking.size >= (craft_number*2) then
- robot.turnRight()
- checking = component.inventory_controller.getStackInSlot(sides.front,1)
- if checking.name == "minecraft:iron_block" then
- if checking.size >= (craft_number) then
- continues = true
- end
- end
- end
- end
- robot.turnRight()
- robot.turnRight()
- if continues then
- tty.clear()
- print("Theire is enought material")
- print("Robot starts his work !")
- print("the robot will stop himself when he will finish")
- os.sleep(2)
- if craft_number > 1 then
- for i=0, craft_number-1, 1 do
- tty.clear()
- io.write("Already ", count," blocks crafted !\n")
- robot.turnRight()
- robot.suck(2)
- robot.turnRight()
- robot.suck(1)
- robot.turnRight()
- robot.turnRight()
- robot.up()
- robot.select(2)
- robot.place()
- robot.up()
- robot.select(1)
- robot.place()
- robot.up()
- robot.up()
- robot.up()
- robot.drop(1)
- robot.down()
- robot.down()
- robot.down()
- robot.down()
- robot.down()
- os.sleep(5)
- count = count+1
- end
- else
- robot.turnRight()
- robot.suck(2)
- robot.turnRight()
- robot.suck(1)
- robot.turnRight()
- robot.turnRight()
- robot.select(2)
- robot.place()
- robot.up()
- robot.select(1)
- robot.place()
- robot.down()
- robot.drop(1)
- end
- Stop()
- else
- print("not enought matherial !/ Or wrong one !")
- os.sleep(3)
- end
- end
- function PlaceThree()
- robot.select(1)
- robot.placeDown()
- for i=0, 1, 1 do
- robot.forward()
- robot.placeDown()
- end
- end
- function PlaceNormalNine() --place a grid of 3*3 blocks
- PlaceThree()
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- PlaceThree()
- robot.turnLeft()
- robot.forward()
- robot.turnLeft()
- PlaceThree()
- for i=0, 1, 1 do
- robot.turnLeft()
- robot.forward()
- robot.forward()
- end
- robot.turnLeft()
- robot.turnLeft()
- end
- function PlaceHollow() --place a grid of 3*3 block with a another block in the center
- PlaceThree()
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- robot.placeDown()
- robot.forward()
- robot.select(2)
- robot.placeDown()
- robot.select(1)
- robot.forward()
- robot.placeDown()
- robot.turnLeft()
- robot.forward()
- robot.turnLeft()
- PlaceThree()
- for i=0, 1, 1 do
- robot.turnLeft()
- robot.forward()
- robot.forward()
- end
- robot.turnLeft()
- robot.turnLeft()
- end
- function MakeNormalCube() --make a normal 3*3*3 compact cube
- robot.up()
- robot.up()
- robot.turnLeft()
- robot.forward()
- robot.turnRight()
- robot.forward()
- PlaceNormalNine()
- robot.up()
- PlaceHollow()
- robot.up()
- PlaceNormalNine()
- robot.turnRight()
- robot.forward()
- robot.turnLeft()
- robot.back()
- robot.up()
- robot.select(3)
- robot.drop(1)
- robot.down()
- robot.down()
- robot.down()
- robot.down()
- robot.down()
- end
- function InfiniteCrafting()
- local waintingTime
- local count = 0
- local pass = false
- tty.clear()
- io.write("You choose to make an infinite crafting\n")
- io.write("Please choose the time between each craft attempt.\n")
- io.write("(In the event of lacking ressources)\n")
- io.write("When you are facing the field:\n")
- io.write(" Inventory on the right need \nwall/obsidian\n")
- io.write(" Inventory on the back need \nGold/Redstone Block\n")
- io.write(" Inventory on the left redstone\npowder/enderpearl\n")
- io.write("Place ender pearle/redstone powder in the left cache\n")
- io.write("Put 999 to return, the time is in seconds\n")
- waintingTime = InputNumber()
- if waintingTime == 999 then
- print("return to menu")
- else
- while true do
- tty.clear()
- robot.select(1)
- io.write("You have already made ", count, " craft(s)\n")
- io.write("To leave the program press ALT+CTRL+C\n")
- io.write("not the best way but mheh that work :p\n")
- robot.turnRight()
- repeat
- checking = component.inventory_controller.getStackInSlot(sides.front,1)
- if checking.size >= 26 then
- pass = true
- else
- tty.clear()
- io.write("You have already made ", count, " craft(s)\n")
- io.write("To leave the program press ALT+CTRL+C\n")
- io.write("not the best way but mheh that work :p\n")
- io.write("waiting for obsidian/wall")
- os.sleep(waintingTime)
- end
- until(pass)
- robot.suck(26)
- pass = false
- robot.turnRight()
- repeat
- checking = component.inventory_controller.getStackInSlot(sides.front,1)
- if checking.size >= 1 then
- pass = true
- else
- tty.clear()
- io.write("You have already made ", count, " craft(s)\n")
- io.write("To leave the program press ALT+CTRL+C\n")
- io.write("not the best way but mheh that work :p\n")
- io.write("waiting for Gold/Redstone Block")
- os.sleep(waintingTime)
- end
- until(pass)
- robot.suck(1)
- pass = false
- robot.turnRight()
- repeat
- checking = component.inventory_controller.getStackInSlot(sides.front,1)
- if checking.size >= 1 then
- pass = true
- else
- tty.clear()
- io.write("You have already made ", count, " craft(s)\n")
- io.write("To leave the program press ALT+CTRL+C\n")
- io.write("not the best way but mheh that work :p\n")
- io.write("waiting for enderpearl/redstone powder")
- os.sleep(waintingTime)
- end
- until(pass)
- robot.suck(1)
- pass = false
- robot.turnRight()
- MakeNormalCube()
- os.sleep(25)--time for craft
- count = count+1
- end
- end
- end
- function SpecifiedCrafting()
- local numbertocraft
- local passing
- local count = 0
- tty.clear()
- io.write("You choose to craft a specified amount\n")
- io.write("Please say of many craft you want\n")
- numbertocraft = InputNumber()
- io.write("You will need:\n")
- io.write((numbertocraft*26)," Block of wall/obsidian\n")
- io.write(numbertocraft," Gold/Redstone Block\n")
- io.write(numbertocraft," redstone powder/enderpearl \n")
- io.write("The robot will check that there is indeed\nthe material\n")
- io.write("When you are facing the field:\n")
- io.write(" Inventory on the right need \nwall/obsidian\n")
- io.write(" Inventory on the back need \nGold/Redstone Block\n")
- io.write(" Inventory on the left redstone\npowder/enderpearl\n")
- io.write("Don't forget to place something to collect the loot !\n")
- io.write("Do you want to continues ?\n")
- io.write("Press any key to continues\n")
- event.pull("key_down")
- --checking
- robot.turnRight()
- checking = component.inventory_controller.getStackInSlot(sides.front,1)
- if checking.size >= (26*numbertocraft) then
- passing = true
- else
- passing = false
- end
- for i=0, 1, 1 do
- robot.turnRight()
- checking = component.inventory_controller.getStackInSlot(sides.front,1)
- if checking.size >= numbertocraft then
- passing = true
- else
- passing = false
- end
- end
- robot.turnRight()
- if passing then
- for i=1, numbertocraft, 1 do
- tty.clear()
- io.write("there are ", (numbertocraft-count), " block left to craft")
- robot.select(1)
- robot.turnRight()
- robot.suck(26)
- robot.turnRight()
- robot.suck(1)
- robot.turnRight()
- robot.suck(1)
- robot.turnRight()
- MakeNormalCube()
- os.sleep(25) --time of craft
- count = count+1
- end
- Stop()
- else
- io.write("not enought material")
- os.sleep(2)
- end
- end
- function MachineMenu() --3*3*3 menu
- local redo2 = false
- tty.clear()
- repeat
- io.write("this program is WIP, the compact cube made with 3 type of block aren't implemented yet\n")
- io.write("Choose your mod of crafting\n")
- io.write("1- Infinite crafting\n")
- io.write("2- Specified amount crafting\n")
- io.write("0- Return\n")
- tempo = InputNumber()
- if tempo == 0 then
- redo2 = true
- tty.clear()
- elseif tempo == 1 then
- redo2 = true
- InfiniteCrafting()
- elseif tempo == 2 then
- redo2 = true
- SpecifiedCrafting()
- else
- tty.clear()
- print("Wrong specification, pease retry !")
- end
- until(redo2)
- end
- function Menu() --menu function
- while true do
- tty.clear()
- io.write("Wellcome to the 0.1 CompactRobot\n")
- io.write("\n-0 Poweroff\n")
- io.write("-1 Making some Wall\n")
- io.write("-2 Making some full 3*3*3 struct ?\n")
- io.write("\nWhat is your choice ? ")
- input = InputNumber()
- if input == 0 then
- Stop()
- elseif input == 1 then
- Wall()
- elseif input == 2 then
- MachineMenu()
- end
- end
- end
- print("Hello, Robot is booting !")
- robot.select(1)
- while robot.detect() do
- robot.turnRight()
- end
- Menu()
Add Comment
Please, Sign In to add comment