Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot");
- local component = require("component")
- local sides = require("sides")
- --local inventory = component.proxy("inventory_controller")
- local inventory = component.inventory_controller
- local os = require("os")
- --wget https://gist.githubusercontent.com/Fingercomp/6563c64d70a4472f26923f78d77caeb9/raw/aa4f461ddee2af70a8040065be8974069e240e27/crash.lua /usr/bin/crash.lua
- --pastebin get [-f] <pastebin code> AutoBuild -- without path it will store the file in the current work directory
- --pastebin get -f YNBDPmTv AutoBuild
- title=CompactMachineStuffs
- author=Griffork
- mats={
- x="blockIron",
- r="blockRedstone",
- m="dustRedstone",
- }
- matloc={
- x=1,
- r=2,
- m=3
- }
- --Size of the space we can build in, probably unused.
- spacex=3
- spacey=3
- spacez=3
- --Location of the power slot.
- powerx=-3
- powery=3
- powerz=1
- --Location of the robot.
- locationx=powerx
- locationy=powery
- locationz=powerz
- --Arrays are also apparently defined with {}
- levels={
- {
- " ",
- " x ",
- " "
- },
- {
- " ",
- " m ",
- " "
- },
- {
- " ",
- " ",
- " "
- }
- }
- function moveTo(x, y, z)
- repeat
- if locationz < z then
- if robot.up() then
- locationz=locationz+1
- else
- os.sleep(1)
- end
- elseif locationz > z then
- if robot.down() then
- locationz=locationz-1
- else
- os.sleep(1)
- end
- end
- until locationz==z
- if locationy < y then
- robot.turnLeft()
- repeat
- if robot.forward() then
- locationy=locationy+1
- else
- os.sleep(1)
- end
- until locationy==y
- robot.turnRight()
- elseif locationy > y then
- robot.turnRight()
- repeat
- if robot.forward() then
- locationy=locationy-1
- else
- os.sleep(1)
- end
- until locationy==y
- robot.turnLeft()
- end
- repeat
- if locationx < x then
- if robot.forward() then
- locationx=locationx+1
- else
- os.sleep(1)
- end
- elseif locationx > x then
- if robot.back() then
- locationx=locationx-1
- else
- os.sleep(1)
- end
- end
- until locationx==x
- end
- repeat
- moveTo(powerx, powery, powerz)
- os.sleep(1)
- robot.turnLeft()
- for i=0, 64, 1 do
- data=inventory.getStackInSlot(sides.front, i)
- if data~=nil then
- print(data.label)
- for name, label in pairs(mats) do
- if label==data.label then
- robot.select(matloc[name])
- inventory.suckFromSlot(sides.front, i)
- end
- end
- end
- end
- robot.turnRight()
- for k=#levels, 0, -1 do
- moveTo(0,0,k)
- for j=#levels[k], 0, -1 do
- for i=string.len(levels[k][j]), 0, -1 do
- --Move 1 back because the block should be at the targeted location.
- moveTo(i,j-1,k)
- block=string.sub(levels[k][j], i, i)
- robot.select(matloc[block])
- robot.place(1)
- end
- end
- end
- until false
Add Comment
Please, Sign In to add comment