Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Copyright (c) 2012 by AyrA
- --You may use this script for free with your Turtle from Computercraft.
- --MAP
- --A Map contains one or multiple Levels
- --Each Level is a 2D Representation of its Layer separated in Rows
- --Each Row contains a specific amount of Blocks in its list.
- --A Block is represented by a single char specifying the slot (A-I) or _ for nothing
- --You do not need to set or change anything except the Map
- --The Script automatically finds out all it needs.
- --The map can have "virtually" any size but you can have maximum 9 Stacks of Items in a Turtle
- --The Map is processed from the First specified Layer to the Last specified.
- --Specify the bottom Layer first and the top Layer last.
- --Each Layer is processed from top to bottom in script (this is left to right in Minecraft).
- -- -> so the Turtle starts from the bottom left and ends at the top right.
- local _=0 --Do nothing
- local A=1 --Place Block in specified slot
- local B=2 --Place Block in specified slot
- local C=3 --Place Block in specified slot
- local D=4 --Place Block in specified slot
- local E=5 --Place Block in specified slot
- local F=6 --Place Block in specified slot
- local G=7 --Place Block in specified slot
- local H=8 --Place Block in specified slot
- local I=9 --Place Block in specified slot
- local MAP=
- {
- --Layer 1 start
- {
- {_,_,_,_,_,_,_,_,_}, --Row 1 (the bottom left)
- {_,_,_,_,_,_,_,_,_}, --Row 2
- {_,_,_,_,_,_,_,_,_}, --...
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_}
- },
- --Layer 1 end
- {
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_}
- },
- {
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,A,A,A,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,A,A,A,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,A,A,A,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_}
- },
- {
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,A,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,A,_,A,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,A,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_}
- },
- {
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,A,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,A,_,A,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,A,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_}
- },
- {
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,_,_,A,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,_,_,A,A,A,_,_,_},
- {_,_,_,_,_,_,_,_,_},
- {_,A,_,_,_,_,_,_,_},
- {_,_,_,_,_,_,_,_,_}
- }
- }
- function u()
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.up()
- end
- function r()
- turtle.turnRight()
- end
- function l()
- turtle.turnLeft()
- end
- function f(num)
- local QQ
- for Q=1,num,1 do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- end
- function p(ID)
- if turtle.detectDown() then
- turtle.digDown()
- end
- if ID>0 and ID<10 then
- turtle.select(ID)
- turtle.placeDown()
- end
- end
- function build()
- local LAYER,ROW,BLOCK
- for LAYER=1,#MAP,1 do
- for ROW=1,#MAP[LAYER],1 do
- for BLOCK=1,#MAP[LAYER][ROW],1 do
- if MAP[LAYER][ROW][BLOCK]==_ then
- --Remove existing block (if any)
- p(0)
- else
- --place specified Block
- p(MAP[LAYER][ROW][BLOCK])
- end
- if BLOCK<#MAP[LAYER][ROW] then
- --Next Block
- f(1)
- else
- --Next Row
- r()
- f(1)
- r()
- f(BLOCK-1)
- r()
- r()
- end
- end
- if ROW==#MAP[LAYER] then
- u()
- l()
- f(#MAP[LAYER])
- r()
- end
- end
- end
- end
- build()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement