Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot");
- local inventory = component.proxy("inventory_controller")
- title:string=CompactMachineStuffs
- author:string=Griffork
- local mats:table={
- x:string="blockIron"
- r:string="blockRedstone"
- m:string="dustRedstone"
- }
- matloc:table={
- x=1
- r=2
- m=3
- }
- --Size of the space we can build in, probably unused.
- spacex:number=3
- spacey:number=3
- spacez:number=3
- --Location of the power slot.
- powerx:number=-3
- powery:number=3
- powerz:number=1
- --Location of the robot.
- locationx:number=powerx
- locationy:number=powery
- locationz:number=powerz
- levels:list=[
- list=[
- string=" "
- string=" x "
- string=" "
- ]
- list=[
- string=" "
- string=" m "
- string=" "
- ]
- list=[
- string=" "
- string=" "
- string=" "
- ]
- ]
- function moveTo(x, y, z)
- repeat
- if locationz < z then
- if robot.up() then
- locationz+=1
- else then
- sleep(1)
- end
- else if locationz > z then
- if robot.down() then
- locationz-=1
- else then
- sleep(1)
- end
- end
- until locationz==z
- if locationy < y then
- robot.turnleft()
- repeat
- if robot.forward() then
- 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-=1
- else then
- sleep(1)
- end
- until locationy==y
- robot.turnleft()
- end
- repeat
- if locationx < x then
- if robot.forward()
- locationx+=1
- else then
- sleep(1)
- end
- else if locationx > x then
- if robot.back() then
- 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
Advertisement
Add Comment
Please, Sign In to add comment