Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot");
- local inventory = component.proxy("inventory_controller")
- --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 MkEwg6mP 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
- levels=[
- list=[
- " ",
- " x ",
- " "
- ],
- list=[
- " ",
- " m ",
- " "
- ],
- list=[
- " ",
- " ",
- " "
- ]
- ]
- function moveTo(x, y, z)
- repeat
- if locationz < z then
- if robot.up() then
- locationz=locationz+1
- else then
- sleep(1)
- end
- else if locationz > z then
- if robot.down() then
- locationz=locationz-1
- else then
- sleep(1)
- end
- end
- until locationz==z
- if locationy < y then
- robot.turnleft()
- repeat
- if robot.forward() then
- locationy=locationy+1
- else then
- sleep(1)
- end
- until locationy==y
- robot.turnright()
- else if locationy > y then
- robot.turnright()
- repeat
- if robot.forward() then
- locationy=locationy-1
- else then
- sleep(1)
- end
- until locationy==y
- robot.turnleft()
- end
- repeat
- if locationx < x then
- if robot.forward()
- locationx=locationx+1
- else then
- sleep(1)
- end
- else if locationx > x then
- if robot.back() then
- locationx=locationx-1
- else then
- sleep(1)
- end
- end
- until locationx==x
- end
- repeat
- moveTo(powerx, powery, powerz)
- sleep(1)
- robot.turnleft()
- for i=0, 64, 1 do
- data = inventory.getStackInSlot(sides.front, i)
- 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
- 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