Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sArg = ...
- function getPaste(key,file)
- local h = http.get("http://pastebin.com/raw/"..textutils.urlEncode(tostring(key)))
- local code = h.readAll()
- h.close()
- local new = fs.open(tostring(file),"w")
- new.write(code)
- new.close()
- end
- if not fs.exists("market") then
- getPaste("BztihKh3" ,"market")
- end
- if not sArg then
- shell.run("market")
- error()
- else
- if not fs.exists(sArg) then
- shell.run("market "..sArg)
- end
- h = fs.open(sArg,"rb")
- end
- Schematic = {
- boundary = {
- --bounds of the schematic
- ['x'] = 0,
- ['y'] = 0,
- ['z'] = 0,
- },
- current = {
- --current position of turtle
- ['x'] = -1,
- ['y'] = 0,
- ['z'] = 0,
- ['direction'] = 0,
- },
- target = {
- --the next objective of where to place the block and what that block is
- ['x'] = 0,
- ['y'] = 0,
- ['z'] = 0,
- ["ascendingY"] = true,
- ["ascendingZ"] = true,
- ["block"] = {
- ["id"] = 0,
- ["name"] = "",
- ["data"] = 0,
- ["slots"] = {
- 0,
- 1,
- 2,
- }
- },
- },
- inventory = {
- --what's inside the turtle's slots
- },
- mt = {},
- new = function()
- local instance = {}
- --shallow copy of functions
- setmetatable(instance,Schematic.mt)
- --deep copy of tables
- local boundary = textutils.serialize(Schematic.boundary)
- local current = textutils.serialize(Schematic.current)
- local target = textutils.serialize(Schematic.target)
- instance.boundary = textutils.unserialize(boundary)
- instance.current = textutils.unserialize(current)
- instance.target = textutils.unserialize(target)
- return instance
- end,
- iterateZ = function(self)
- if self.target.ascendingZ then
- if self.target.z < self.boundary.z then
- self.target.z = self.target.z + 1
- else
- self:iterateY()
- self.target.ascendingZ = false
- end
- else
- if self.target.z > 0 then
- self.target.z = self.target.z - 1
- else
- self:iterateY()
- self.target.ascendingZ = true
- end
- end
- end,
- iterateY = function(self)
- if self.target.ascendingY then
- if self.target.y < self.boundary.y then
- self.target.y = self.target.y + 1
- else
- self:iterateX()
- self.target.ascendingY = false
- end
- else
- if self.target.y > 0 then
- self.target.y = self.target.y - 1
- else
- self:iterateX()
- self.target.ascendingY = true
- end
- end
- end,
- iterateX = function(self)
- if self.target.x < self.boundary.x then
- self.target.x = self.target.x + 1
- else
- print("finished")
- self:goto(self.boundary.x,-1,-1)
- self:goto(-1,-1,-1)
- self:turn(0)
- error()
- end
- end,
- turnRight = function(self)
- turtle.turnRight()
- self.current.direction = (self.current.direction + 1)%4
- end,
- turnLeft = function(self)
- turtle.turnLeft()
- self.current.direction = (self.current.direction - 1)%4
- end,
- forward = function(self)
- while not turtle.forward() do
- turtle.dig()
- end
- if self.current.direction == 0 then
- self.current.z = self.current.z + 1
- elseif self.current.direction == 1 then
- self.current.y = self.current.y - 1
- elseif self.current.direction == 2 then
- self.current.z = self.current.z - 1
- elseif self.current.direction == 3 then
- self.current.y = self.current.y + 1
- end
- end,
- up = function(self)
- while not turtle.up() do
- turtle.digUp()
- end
- self.current.x = self.current.x + 1
- end,
- down = function(self)
- while not turtle.down() do
- turtle.digDown()
- end
- self.current.x = self.current.x - 1
- end,
- place = function(self)
- while not turtle.placeDown() do
- turtle.digDown()
- end
- local n = turtle.getSelectedSlot()
- self.inventory[n].count = self.inventory[n].count - 1
- end,
- turn = function(self,direction)
- --0,1,2,3
- --make more efficient later
- local leftDirection = (self.current.direction - 1)%4
- if leftDirection == direction then
- self:turnLeft()
- else
- while self.current.direction ~= direction do
- self:turnRight()
- end
- end
- end,
- goto = function(self,heightGoal,widthGoal,lengthGoal)
- heightGoal = heightGoal or self.target.x
- widthGoal = widthGoal or self.target.y
- lengthGoal = lengthGoal or self.target.z
- while heightGoal > self.current.x do
- self:up()
- end
- while heightGoal < self.current.x do
- self:down()
- end
- if widthGoal > self.current.y then
- self:turn(3)
- while widthGoal > self.current.y do
- self:forward()
- end
- elseif widthGoal < self.current.y then
- self:turn(1)
- while widthGoal < self.current.y do
- self:forward()
- end
- end
- if lengthGoal > self.current.z then
- self:turn(0)
- while lengthGoal > self.current.z do
- self:forward()
- end
- elseif lengthGoal < self.current.z then
- self:turn(2)
- while lengthGoal < self.current.z do
- self:forward()
- end
- end
- end,
- recordInventory = function(self,nBlock,nData)
- --given int blockID and int nData, find the item in the turtle's inventory
- local s = turtle.getSelectedSlot() - 1
- for n = s,s+15 do
- n = (n%16)+1
- turtle.select(n)
- local tData = turtle.getItemDetail(n)
- self.inventory[n] = tData
- end
- end,
- select = function(self,nBlock,nData)
- --find the block using the inventory table
- local s = turtle.getSelectedSlot() - 1
- for n = s,(s+15) do
- n = n%16
- n = n + 1
- local tData = self.inventory[n]
- if tData and block_name[nBlock] and tData.name == block_name[nBlock] and tData.count > 0 then
- --if an item is there and the id matches a blockName and that blockName matches the itemName and there is some left then
- if nBlock == 35 or nBlock == 5 or nBlock ==17 or nBlock == 98 or nBlock ==159 or nBlock == 160 or nBlock == 171 then
- --if it's wool or wood or stone bricks then check the data
- if tData.damage == nData then
- return n
- end
- else
- --otherwise the block_id matching is good enough
- return n
- end
- end
- end
- end,
- }
- Schematic.mt.__index = Schematic
- Schematic.mt.__tostring = function(self)
- return tostring(self.current.x).." "..tostring(self.current.y).." "..tostring(self.current.z)
- end
- block_name = {
- "minecraft:stone",
- "minecraft:grass",
- "minecraft:dirt",
- "minecraft:cobblestone",
- "minecraft:planks",
- "minecraft:sapling",
- "minecraft:bedrock",
- "minecraft:flowing_water",
- "minecraft:water",
- "minecraft:flowing_lava",
- "minecraft:lava",
- "minecraft:sand",
- "minecraft:gravel",
- "minecraft:gold_ore",
- "minecraft:iron_ore",
- "minecraft:coal_ore",
- "minecraft:log",
- "minecraft:leaves",
- "minecraft:sponge",
- "minecraft:glass",
- "minecraft:lapis_ore",
- "minecraft:lapis_block",
- "minecraft:dispenser",
- "minecraft:sandstone",
- "minecraft:noteblock",
- "minecraft:bed",
- "minecraft:golden_rail",
- "minecraft:detector_rail",
- "minecraft:sticky_piston",
- "minecraft:web",
- "minecraft:tallgrass",
- "minecraft:deadbush",
- "minecraft:piston",
- "minecraft:piston_head",
- "minecraft:wool",
- [ 37 ] = "minecraft:yellow_flower",
- [ 38 ] = "minecraft:red_flower",
- [ 39 ] = "minecraft:brown_mushroom",
- [ 40 ] = "minecraft:red_mushroom",
- [ 41 ] = "minecraft:gold_block",
- [ 42 ] = "minecraft:iron_block",
- [ 43 ] = "minecraft:double_stone_slab",
- [ 44 ] = "minecraft:stone_slab",
- [ 45 ] = "minecraft:brick_block",
- [ 46 ] = "minecraft:tnt",
- [ 47 ] = "minecraft:bookshelf",
- [ 48 ] = "minecraft:mossy_cobblestone",
- [ 49 ] = "minecraft:obsidian",
- [ 50 ] = "minecraft:torch",
- [ 51 ] = "minecraft:fire",
- [ 52 ] = "minecraft:mob_spawner",
- [ 53 ] = "minecraft:oak_stairs",
- [ 54 ] = "minecraft:chest",
- [ 55 ] = "minecraft:redstone_wire",
- [ 56 ] = "minecraft:diamond_ore",
- [ 57 ] = "minecraft:diamond_block",
- [ 58 ] = "minecraft:crafting_table",
- [ 59 ] = "minecraft:wheat",
- [ 60 ] = "minecraft:farmland",
- [ 61 ] = "minecraft:furnace",
- [ 62 ] = "minecraft:lit_furnace",
- [ 63 ] = "minecraft:standing_sign",
- [ 64 ] = "minecraft:wooden_door",
- [ 65 ] = "minecraft:ladder",
- [ 66 ] = "minecraft:rail",
- [ 67 ] = "minecraft:stone_stairs",
- [ 68 ] = "minecraft:wall_sign",
- [ 69 ] = "minecraft:lever",
- [ 70 ] = "minecraft:stone_pressure_plate",
- [ 71 ] = "minecraft:iron_door",
- [ 72 ] = "minecraft:wooden_pressure_plate",
- [ 73 ] = "minecraft:redstone_ore",
- [ 74 ] = "minecraft:lit_redstone_ore",
- [ 75 ] = "off",
- [ 78 ] = "minecraft:snow_layer",
- [ 79 ] = "minecraft:ice",
- [ 80 ] = "minecraft:snow",
- [ 81 ] = "minecraft:cactus",
- [ 82 ] = "minecraft:clay",
- [ 83 ] = "minecraft:reeds",
- [ 84 ] = "minecraft:jukebox",
- [ 85 ] = "minecraft:fence",
- [ 86 ] = "minecraft:pumpkin",
- [ 87 ] = "minecraft:netherrack",
- [ 88 ] = "minecraft:soul_sand",
- [ 89 ] = "minecraft:glowstone",
- [ 90 ] = "minecraft:portal",
- [ 91 ] = "minecraft:lit_pumpkin",
- [ 92 ] = "minecraft:cake",
- [ 93 ] = "off",
- [ 96 ] = "minecraft:trapdoor",
- [ 97 ] = "minecraft:monster_egg",
- [ 98 ] = "minecraft:stonebrick",
- [ 99 ] = "minecraft:brown_mushroom_block",
- [ 100 ] = "minecraft:red_mushroom_block",
- [ 101 ] = "minecraft:iron_bars",
- [ 102 ] = "minecraft:glass_pane",
- [ 103 ] = "minecraft:melon_block",
- [ 104 ] = "minecraft:pumpkin_stem",
- [ 105 ] = "minecraft:melon_stem",
- [ 106 ] = "minecraft:vine",
- [ 107 ] = "minecraft:fence_gate",
- [ 108 ] = "minecraft:brick_stairs",
- [ 109 ] = "minecraft:stone_brick_stairs",
- [ 110 ] = "minecraft:mycelium",
- [ 111 ] = "minecraft:waterlily",
- [ 112 ] = "minecraft:nether_brick",
- [ 113 ] = "minecraft:nether_brick_fence",
- [ 114 ] = "minecraft:nether_brick_stairs",
- [ 115 ] = "minecraft:nether_wart",
- [ 116 ] = "minecraft:enchanting_table",
- [ 117 ] = "minecraft:brewing_stand",
- [ 118 ] = "minecraft:cauldron",
- [ 119 ] = "minecraft:end_portal",
- [ 120 ] = "minecraft:end_portal_frame",
- [ 121 ] = "minecraft:end_stone",
- [ 122 ] = "minecraft:dragon_egg",
- [ 123 ] = "inactive",
- [ 126 ] = "minecraft:wooden_slab",
- [ 127 ] = "minecraft:cocoa",
- [ 128 ] = "minecraft:sandstone_stairs",
- [ 129 ] = "minecraft:emerald_ore",
- [ 130 ] = "minecraft:ender_chest",
- [ 131 ] = "minecraft:tripwire_hook",
- [ 132 ] = "minecraft:tripwire_hook",
- [ 133 ] = "minecraft:emerald_block",
- [ 134 ] = "minecraft:spruce_stairs",
- [ 135 ] = "minecraft:birch_stairs",
- [ 136 ] = "minecraft:jungle_stairs",
- [ 137 ] = "minecraft:command_block",
- [ 138 ] = "minecraft:beacon",
- [ 139 ] = "minecraft:cobblestone_wall",
- [ 140 ] = "minecraft:flower_pot",
- [ 141 ] = "minecraft:carrots",
- [ 142 ] = "minecraft:potatoes",
- [ 143 ] = "minecraft:wooden_button",
- [ 144 ] = "minecraft:skull",
- [ 145 ] = "minecraft:anvil",
- [ 146 ] = "minecraft:trapped_chest",
- [ 147 ] = "light",
- [ 152 ] = "minecraft:redstone_block",
- [ 153 ] = "minecraft:quartz_ore",
- [ 154 ] = "minecraft:hopper",
- [ 155 ] = "minecraft:quartz_block",
- [ 156 ] = "minecraft:quartz_stairs",
- [ 157 ] = "minecraft:activator_rail",
- [ 158 ] = "minecraft:dropper",
- [ 159 ] = "minecraft:stained_hardened_clay",
- [ 160 ] = "minecraft:stained_glass_pane",
- [ 161 ] = "minecraft:leaves2",
- [ 162 ] = "minecraft:log2",
- [ 163 ] = "minecraft:acacia_stairs",
- [ 164 ] = "minecraft:dark_oak_stairs",
- [ 165 ] = "minecraft:slime",
- [ 166 ] = "minecraft:barrier",
- [ 167 ] = "minecraft:iron_trapdoor",
- [ 168 ] = "minecraft:prismarine",
- [ 169 ] = "minecraft:sea_lantern",
- [ 170 ] = "minecraft:hay_block",
- [ 171 ] = "minecraft:carpet",
- [ 172 ] = "minecraft:hardened_clay",
- [ 173 ] = "minecraft:coal_block",
- [ 174 ] = "minecraft:packed_ice",
- [ 175 ] = "minecraft:double_plant",
- [ 176 ] = "minecraft:standing_banner",
- [ 177 ] = "minecraft:wall_banner",
- [ 178 ] = "minecraft:daylight_detector_inverted",
- [ 179 ] = "minecraft:red_sandstone",
- [ 180 ] = "minecraft:red_sandstone_stairs",
- [ 181 ] = "minecraft:double_stone_slab2",
- [ 182 ] = "minecraft:stone_slab2",
- [ 183 ] = "minecraft:spruce_fence_gate",
- [ 184 ] = "minecraft:birch_fence_gate",
- [ 185 ] = "minecraft:jungle_fence_gate",
- [ 186 ] = "minecraft:dark_oak_fence_gate",
- [ 187 ] = "minecraft:acacia_fence_gate",
- [ 188 ] = "minecraft:spruce_fence",
- [ 189 ] = "minecraft:birch_fence",
- [ 190 ] = "minecraft:jungle_fence",
- [ 191 ] = "minecraft:dark_oak_fence",
- [ 192 ] = "minecraft:acacia_fence",
- [ 193 ] = "minecraft:spruce_door",
- [ 194 ] = "minecraft:birch_door",
- [ 195 ] = "minecraft:jungle_door",
- [ 196 ] = "minecraft:acacia_door",
- [ 197 ] = "minecraft:dark_oak_door",
- [ 198 ] = "minecraft:end_rod",
- [ 199 ] = "minecraft:chorus_plant",
- [ 200 ] = "minecraft:chorus_flower",
- [ 201 ] = "minecraft:purpur_block",
- [ 202 ] = "minecraft:purpur_pillar",
- [ 203 ] = "minecraft:purpur_stairs",
- [ 204 ] = "minecraft:purpur_double_slab",
- [ 205 ] = "minecraft:purpur_slab",
- [ 206 ] = "minecraft:end_bricks",
- [ 207 ] = "minecraft:beetroots",
- [ 208 ] = "minecraft:grass_path",
- [ 209 ] = "minecraft:end_gateway",
- [ 210 ] = "minecraft:repeating_command_block",
- [ 211 ] = "minecraft:chain_command_block",
- [ 212 ] = "minecraft:frosted_ice",
- [ 213 ] = "minecraft:magma",
- [ 214 ] = "minecraft:nether_wart_block",
- [ 215 ] = "minecraft:red_nether_brick",
- [ 216 ] = "minecraft:bone_block",
- [ 217 ] = "minecraft:structure_void",
- [ 218 ] = "minecraft:observer",
- [ 219 ] = "minecraft:white_shulker_box",
- [ 220 ] = "minecraft:orange_shulker_box",
- [ 221 ] = "minecraft:magenta_shulker_box",
- [ 222 ] = "minecraft:light_blue_shulker_box",
- [ 223 ] = "minecraft:yellow_shulker_box",
- [ 224 ] = "minecraft:lime_shulker_box",
- [ 225 ] = "minecraft:pink_shulker_box",
- [ 226 ] = "minecraft:gray_shulker_box",
- [ 227 ] = "minecraft:silver_shulker_box",
- [ 228 ] = "minecraft:cyan_shulker_box",
- [ 229 ] = "minecraft:purple_shulker_box",
- [ 230 ] = "minecraft:blue_shulker_box",
- [ 231 ] = "minecraft:brown_shulker_box",
- [ 232 ] = "minecraft:green_shulker_box",
- [ 233 ] = "minecraft:red_shulker_box",
- [ 234 ] = "minecraft:black_shulker_box",
- [ 235 ] = "minecraft:white_glazed_terracotta",
- [ 236 ] = "minecraft:orange_glazed_terracotta",
- [ 237 ] = "minecraft:magenta_glazed_terracotta",
- [ 238 ] = "minecraft:light_blue_glazed_terracotta",
- [ 239 ] = "minecraft:yellow_glazed_terracotta",
- [ 240 ] = "minecraft:lime_glazed_terracotta",
- [ 241 ] = "minecraft:pink_glazed_terracotta",
- [ 242 ] = "minecraft:gray_glazed_terracotta",
- [ 243 ] = "minecraft:light_gray_glazed_terracotta",
- [ 244 ] = "minecraft:cyan_glazed_terracotta",
- [ 245 ] = "minecraft:purple_glazed_terracotta",
- [ 246 ] = "minecraft:blue_glazed_terracotta",
- [ 247 ] = "minecraft:brown_glazed_terracotta",
- [ 248 ] = "minecraft:green_glazed_terracotta",
- [ 249 ] = "minecraft:red_glazed_terracotta",
- [ 250 ] = "minecraft:black_glazed_terracotta",
- [ 251 ] = "minecraft:concrete",
- [ 252 ] = "minecraft:concrete_powder",
- [ 255 ] = "minecraft:structure_block",
- [ 256 ] = "minecraft:iron_shovel",
- [ 257 ] = "minecraft:iron_pickaxe",
- [ 258 ] = "minecraft:iron_axe",
- [ 259 ] = "minecraft:flint_and_steel",
- [ 260 ] = "minecraft:apple",
- [ 261 ] = "minecraft:bow",
- [ 262 ] = "minecraft:arrow",
- [ 263 ] = "minecraft:coal",
- [ 264 ] = "minecraft:diamond",
- [ 265 ] = "minecraft:iron_ingot",
- [ 266 ] = "minecraft:gold_ingot",
- [ 267 ] = "minecraft:iron_sword",
- [ 268 ] = "minecraft:wooden_sword",
- [ 269 ] = "minecraft:wooden_shovel",
- [ 270 ] = "minecraft:wooden_pickaxe",
- [ 271 ] = "minecraft:wooden_axe",
- [ 272 ] = "minecraft:stone_sword",
- [ 273 ] = "minecraft:stone_shovel",
- [ 274 ] = "minecraft:stone_pickaxe",
- [ 275 ] = "minecraft:stone_axe",
- [ 276 ] = "minecraft:diamond_sword",
- [ 277 ] = "minecraft:diamond_shovel",
- [ 278 ] = "minecraft:diamond_pickaxe",
- [ 279 ] = "minecraft:diamond_axe",
- [ 280 ] = "minecraft:stick",
- [ 281 ] = "minecraft:bowl",
- [ 282 ] = "minecraft:mushroom_stew",
- [ 283 ] = "minecraft:golden_sword",
- [ 284 ] = "minecraft:golden_shovel",
- [ 285 ] = "minecraft:golden_pickaxe",
- [ 286 ] = "minecraft:golden_axe",
- [ 287 ] = "minecraft:string",
- [ 288 ] = "minecraft:feather",
- [ 289 ] = "minecraft:gunpowder",
- [ 290 ] = "minecraft:wooden_hoe",
- [ 291 ] = "minecraft:stone_hoe",
- [ 292 ] = "minecraft:iron_hoe",
- [ 293 ] = "minecraft:diamond_hoe",
- [ 294 ] = "minecraft:golden_hoe",
- [ 295 ] = "minecraft:wheat_seeds",
- [ 296 ] = "minecraft:wheat",
- [ 297 ] = "minecraft:bread",
- [ 298 ] = "minecraft:leather_helmet",
- [ 299 ] = "minecraft:leather_chestplate",
- [ 300 ] = "minecraft:leather_leggings",
- [ 301 ] = "minecraft:leather_boots",
- [ 302 ] = "minecraft:chainmail_helmet",
- [ 303 ] = "minecraft:chainmail_chestplate",
- [ 304 ] = "minecraft:chainmail_leggings",
- [ 305 ] = "minecraft:chainmail_boots",
- [ 306 ] = "minecraft:iron_helmet",
- [ 307 ] = "minecraft:iron_chestplate",
- [ 308 ] = "minecraft:iron_leggings",
- [ 309 ] = "minecraft:iron_boots",
- [ 310 ] = "minecraft:diamond_helmet",
- [ 311 ] = "minecraft:diamond_chestplate",
- [ 312 ] = "minecraft:diamond_leggings",
- [ 313 ] = "minecraft:diamond_boots",
- [ 314 ] = "minecraft:golden_helmet",
- [ 315 ] = "minecraft:golden_chestplate",
- [ 316 ] = "minecraft:golden_leggings",
- [ 317 ] = "minecraft:golden_boots",
- [ 318 ] = "minecraft:flint",
- [ 319 ] = "minecraft:porkchop",
- [ 320 ] = "minecraft:cooked_porkchop",
- [ 321 ] = "minecraft:painting",
- [ 322 ] = "minecraft:golden_apple",
- [ 323 ] = "minecraft:sign",
- [ 324 ] = "minecraft:wooden_door",
- [ 325 ] = "minecraft:bucket",
- [ 326 ] = "minecraft:water_bucket",
- [ 327 ] = "minecraft:lava_bucket",
- [ 328 ] = "minecraft:minecart",
- [ 329 ] = "minecraft:saddle",
- [ 330 ] = "minecraft:iron_door",
- [ 331 ] = "minecraft:redstone",
- [ 332 ] = "minecraft:snowball",
- [ 333 ] = "minecraft:boat",
- [ 334 ] = "minecraft:leather",
- [ 335 ] = "minecraft:milk_bucket",
- [ 336 ] = "minecraft:brick",
- [ 337 ] = "minecraft:clay_ball",
- [ 338 ] = "minecraft:reeds",
- [ 339 ] = "minecraft:paper",
- [ 340 ] = "minecraft:book",
- [ 341 ] = "minecraft:slime_ball",
- [ 342 ] = "minecraft:chest_minecart",
- [ 343 ] = "minecraft:furnace_minecart",
- [ 344 ] = "minecraft:egg",
- [ 345 ] = "minecraft:compass",
- [ 346 ] = "minecraft:fishing_rod",
- [ 347 ] = "minecraft:clock",
- [ 348 ] = "minecraft:glowstone_dust",
- [ 349 ] = "minecraft:fish",
- [ 350 ] = "minecraft:cooked_fish",
- [ 351 ] = "minecraft:dye",
- [ 352 ] = "minecraft:bone",
- [ 353 ] = "minecraft:sugar",
- [ 354 ] = "minecraft:cake",
- [ 355 ] = "minecraft:bed",
- [ 356 ] = "minecraft:repeater",
- [ 357 ] = "minecraft:cookie",
- [ 358 ] = "minecraft:filled_map",
- [ 359 ] = "minecraft:shears",
- [ 360 ] = "minecraft:melon",
- [ 361 ] = "minecraft:pumpkin_seeds",
- [ 362 ] = "minecraft:melon_seeds",
- [ 363 ] = "minecraft:beef",
- [ 364 ] = "minecraft:cooked_beef",
- [ 365 ] = "minecraft:chicken",
- [ 366 ] = "minecraft:cooked_chicken",
- [ 367 ] = "minecraft:rotten_flesh",
- [ 368 ] = "minecraft:ender_pearl",
- [ 369 ] = "minecraft:blaze_rod",
- [ 370 ] = "minecraft:ghast_tear",
- [ 371 ] = "minecraft:gold_nugget",
- [ 372 ] = "minecraft:nether_wart",
- [ 373 ] = "minecraft:potion",
- [ 374 ] = "minecraft:glass_bottle",
- [ 375 ] = "minecraft:spider_eye",
- [ 376 ] = "minecraft:fermented_spider_eye",
- [ 377 ] = "minecraft:blaze_powder",
- [ 378 ] = "minecraft:magma_cream",
- [ 379 ] = "minecraft:brewing_stand",
- [ 380 ] = "minecraft:cauldron",
- [ 381 ] = "minecraft:ender_eye",
- [ 382 ] = "minecraft:speckled_melon",
- [ 384 ] = "minecraft:experience_bottle",
- [ 385 ] = "minecraft:fire_charge",
- [ 386 ] = "minecraft:writable_book",
- [ 387 ] = "minecraft:written_book",
- [ 388 ] = "minecraft:emerald",
- [ 389 ] = "minecraft:item_frame",
- [ 390 ] = "minecraft:flower_pot",
- [ 391 ] = "minecraft:carrot",
- [ 392 ] = "minecraft:potato",
- [ 393 ] = "minecraft:baked_potato",
- [ 394 ] = "minecraft:poisonous_potato",
- [ 395 ] = "minecraft:map",
- [ 396 ] = "minecraft:golden_carrot",
- [ 397 ] = "Skeleton",
- [ 399 ] = "minecraft:nether_star",
- [ 400 ] = "minecraft:pumpkin_pie",
- [ 401 ] = "minecraft:fireworks",
- [ 402 ] = "minecraft:firework_charge",
- [ 403 ] = "minecraft:enchanted_book",
- [ 404 ] = "minecraft:comparator",
- [ 405 ] = "minecraft:netherbrick",
- [ 406 ] = "minecraft:quartz",
- [ 407 ] = "minecraft:tnt_minecart",
- [ 408 ] = "minecraft:hopper_minecart",
- [ 409 ] = "minecraft:prismarine_shard",
- [ 410 ] = "minecraft:prismarine_crystals",
- [ 411 ] = "minecraft:rabbit",
- [ 412 ] = "minecraft:cooked_rabbit",
- [ 413 ] = "minecraft:rabbit_stew",
- [ 414 ] = "minecraft:rabbit_foot",
- [ 415 ] = "minecraft:rabbit_hide",
- [ 416 ] = "minecraft:armor_stand",
- [ 417 ] = "minecraft:iron_horse_armor",
- [ 418 ] = "minecraft:golden_horse_armor",
- [ 419 ] = "minecraft:diamond_horse_armor",
- [ 420 ] = "minecraft:lead",
- [ 421 ] = "minecraft:name_tag",
- [ 422 ] = "minecraft:command_block_minecart",
- [ 423 ] = "minecraft:mutton",
- [ 424 ] = "minecraft:cooked_mutton",
- [ 425 ] = "minecraft:banner",
- [ 426 ] = "minecraft:end_crystal",
- [ 427 ] = "minecraft:spruce_door",
- [ 428 ] = "minecraft:birch_door",
- [ 429 ] = "minecraft:jungle_door",
- [ 430 ] = "minecraft:acacia_door",
- [ 431 ] = "minecraft:dark_oak_door",
- [ 432 ] = "minecraft:chorus_fruit",
- [ 433 ] = "minecraft:popped_chorus_fruit",
- [ 434 ] = "minecraft:beetroot",
- [ 435 ] = "minecraft:beetroot_seeds",
- [ 436 ] = "minecraft:beetroot_soup",
- [ 437 ] = "minecraft:dragon_breath",
- [ 438 ] = "minecraft:splash_potion",
- [ 439 ] = "minecraft:spectral_arrow",
- [ 440 ] = "minecraft:tipped_arrow",
- [ 441 ] = "minecraft:lingering_potion",
- [ 442 ] = "minecraft:shield",
- [ 443 ] = "minecraft:elytra",
- [ 444 ] = "minecraft:spruce_boat",
- [ 445 ] = "minecraft:birch_boat",
- [ 446 ] = "minecraft:jungle_boat",
- [ 447 ] = "minecraft:acacia_boat",
- [ 448 ] = "minecraft:dark_oak_boat",
- [ 449 ] = "minecraft:totem_of_undying",
- [ 450 ] = "minecraft:shulker_shell",
- [ 452 ] = "minecraft:iron_nugget",
- [ 453 ] = "minecraft:knowledge_book",
- [ 0 ] = "minecraft:air",
- [ 2261 ] = "minecraft:record_mall",
- [ 2262 ] = "minecraft:record_mellohi",
- [ 2263 ] = "minecraft:record_stal",
- [ 2264 ] = "minecraft:record_strad",
- [ 2265 ] = "minecraft:record_ward",
- [ 2266 ] = "minecraft:record_11",
- [ 2267 ] = "minecraft:record_wait",
- [ 2256 ] = "minecraft:record_13",
- [ 2257 ] = "minecraft:record_cat",
- [ 2258 ] = "minecraft:record_blocks",
- [ 2259 ] = "minecraft:record_chirp",
- [ 2260 ] = "minecraft:record_far",
- }
- --[[function findMaterials(nBlock,nData)
- --given int blockID and int nData, find the item in the turtle's inventory
- for n = 1,16 do
- turtle.select(n)
- local tData = turtle.getItemDetail(n)
- if tData and block_name[nBlock] and tData.name == block_name[nBlock] then
- if nBlock == 35 or nBlock == 5 or nBlock ==17 or nBlock == 98 or nBlock ==159 or nBlock == 160 or nBlock == 171 then
- if tData.damage == nData then
- return n
- end
- else
- return n
- end
- end
- end
- end]]
- --textutils.pagedPrint(textutils.serialize(findMaterials(50,0)))
- local block_id = {}
- block_id[0] = "Air"
- block_id[1] = "Stone"
- block_id[2] = "Grass"
- block_id[3] = "Dirt"
- block_id[4] = "Cobblestone"
- block_id[5] = "Wood Planks"
- block_id[6] = "Sapling"
- block_id[7] = "Bedrock"
- block_id[8] = "Water"
- block_id[9] = "Stationary water"
- block_id[10] = "Lava"
- block_id[11] = "Stationary lava"
- block_id[12] = "Sand"
- block_id[13] = "Gravel"
- block_id[14] = "Gold Ore"
- block_id[15] = "Iron (Ore)"
- block_id[16] = "Coal Ore"
- block_id[17] = "Wood"
- block_id[18] = "Leaves"
- block_id[19] = "Sponge"
- block_id[20] = "Glass"
- block_id[21] = "Lapis Lazuli (Ore)"
- block_id[22] = "Lapis Lazuli (Block)"
- block_id[23] = "Dispenser"
- block_id[24] = "Sandstone"
- block_id[25] = "Note Block Tile entity"
- block_id[26] = "Bed"
- block_id[27] = "Powered Rail "
- block_id[28] = "Detector Rail "
- block_id[29] = "Sticky Piston"
- block_id[30] = "Cobweb"
- block_id[31] = "Tall Grass"
- block_id[32] = "Dead Bush"
- block_id[33] = "Piston"
- block_id[34] = "Piston Extension"
- block_id[35] = "Wool"
- block_id[36] = "Block moved by Piston"
- block_id[37] = "Dandelionandelion"
- block_id[38] = "Rose"
- block_id[39] = "Brown Mushroom"
- block_id[40] = "Red Mushroom"
- block_id[41] = "Block of Gold"
- block_id[42] = "Block of Iron"
- block_id[43] = "Double Slabs"
- block_id[44] = "Slabs"
- block_id[45] = "Brick Block"
- block_id[46] = "TNT"
- block_id[47] = "Bookshelf"
- block_id[48] = "Moss Stone"
- block_id[49] = "Obsidian"
- block_id[50] = "Torch"
- block_id[51] = "Fire"
- block_id[52] = "Monster Spawner"
- block_id[53] = "Wooden Stairs"
- block_id[54] = "Chest"
- block_id[55] = "Redstone (Wire)"
- block_id[56] = "Diamond (Ore)"
- block_id[57] = "Block of Diamond"
- block_id[58] = "Crafting Table"
- block_id[59] = "Seeds"
- block_id[60] = "Farland"
- block_id[61] = "Furnace"
- block_id[62] = "Burning Furnace"
- block_id[63] = "Sign Post"
- block_id[64] = "Wooden Door"
- block_id[65] = "Ladders"
- block_id[66] = "Rails"
- block_id[67] = "Cobblestone Stairs"
- block_id[68] = "Wall Sign"
- block_id[69] = "Lever"
- block_id[70] = "Stone Pressure Plate"
- block_id[71] = "Iron Door"
- block_id[72] = "Wooden Pressure Plates"
- block_id[73] = "Redstone Ore"
- block_id[74] = "Glowing Redstone Ore"
- block_id[75] = "Redstone Torch"
- block_id[76] = "Redstone Torch"
- block_id[77] = "Stone Button "
- block_id[78] = "Snow"
- block_id[79] = "Ice"
- block_id[80] = "Snow Block"
- block_id[81] = "Cactus"
- block_id[82] = "Clay (Block)"
- block_id[83] = "Sugar Cane"
- block_id[84] = "Jukebox"
- block_id[85] = "Fence"
- block_id[86] = "Pumpkin"
- block_id[87] = "Netherrack"
- block_id[88] = "Soul Sand"
- block_id[89] = "Glowstone"
- block_id[90] = "Portal"
- block_id[91] = "Jack-O-Lantern"
- block_id[92] = "Cake Block"
- block_id[93] = "Redstone Repeater"
- block_id[94] = "Redstone Repeater"
- block_id[95] = "Stained Glass"
- block_id[96] = "Trapdoors"
- block_id[97] = "Hidden Silverfish"
- block_id[98] = "Stone Bricks"
- block_id[99] = "Huge brown and red mushroom"
- block_id[100] = "Huge brown and red mushroom"
- block_id[101] = "Iron Bars"
- block_id[102] = "Glass Pane"
- block_id[103] = "Melon"
- block_id[104] = "Pumpkin Stem"
- block_id[105] = "Melon Stem"
- block_id[106] = "Vines"
- block_id[107] = "Fence Gate"
- block_id[108] = "Brick Stairs"
- block_id[109] = "Stone Brick Stairs"
- block_id[110] = "Mycelium"
- block_id[111] = "Lily Pad"
- block_id[112] = "Nether Brick"
- block_id[113] = "Nether Brick Fence"
- block_id[114] = "Nether Brick Stairs"
- block_id[115] = "Nether Wart"
- block_id[116] = "Enchantment Table"
- block_id[117] = "Brewing Stand"
- block_id[118] = "Cauldron"
- block_id[119] = "End Portal"
- block_id[120] = "End Portal Frame"
- block_id[121] = "End Stone "
- block_id[126] = "Wood Slabs"
- block_id[128] = "Sandstone Stairs"
- block_id[134] = "Spruce Wood Stairs"
- block_id[135] = "Birch Wood Stairs"
- block_id[136] = "Jungle Wood Stairs"
- block_id[156] = "Quartz Stairs"
- block_id[159] = "Stained Clay"
- block_id[160] = "Stained Glass Pane"
- block_id[163] = "Acacia Wood Stairs"
- block_id[164] = "Dark Oak Wood Stairs"
- block_id[171] = "Carpet"
- block_id[172] = "Hardened Clay"
- block_id[256] = "Iron Ingotron Shovel"
- block_id[257] = "Iron Pickaxe"
- block_id[258] = "Iron Axe"
- block_id[259] = "Flint and Steel"
- block_id[260] = "Red Apple"
- block_id[261] = "Bow"
- block_id[262] = "Arrow"
- block_id[263] = "Coal"
- local woolColors = {}
- woolColors[0] = "White"
- woolColors[1] = "Orange"
- woolColors[2] = "Magenta"
- woolColors[3] = "Light Blue"
- woolColors[4] = "Yellow"
- woolColors[5] = "Lime"
- woolColors[6] = "Pink"
- woolColors[7] = "Gray"
- woolColors[8] = "Light Gray"
- woolColors[9] = "Cyan"
- woolColors[10] = "Purple"
- woolColors[11] = "Blue"
- woolColors[12] = "Brown"
- woolColors[13] = "Green"
- woolColors[14] = "Red"
- woolColors[15] = "Black"
- local woodTypes = {}
- woodTypes[0] = "Oak"
- woodTypes[1] = "Spruce"
- woodTypes[2] = "Birch"
- woodTypes[3] = "Jungle"
- woodTypes[4] = "Acacia"
- woodTypes[5] = "Dark Oak"
- local stairOrientation = {}
- stairOrientation[0] = "East"
- stairOrientation[1] = "West"
- stairOrientation[2] = "South"
- stairOrientation[3] = "North"
- stairOrientation[4] = "East Inverted"
- stairOrientation[5] = "West Inverted"
- stairOrientation[6] = "South Inverted"
- stairOrientation[7] = "North Inverted"
- local length = 0
- local height = 0
- local width = 0
- local blocks = {}
- local data = {}
- function getBlockName(id, blockData)
- blockData = blockData or nil
- if(block_id[id] == nil) then
- return "UNKNOWN"
- else
- if(blockData) then
- if(id == 35) then
- str = woolColors[blockData] .. " " .. block_id[id]
- return str
- end
- end
- return block_id[id]
- end
- end
- function getBlockId(x,y,z)
- return blocks[y + z*width + x*length*width + 1]
- end
- function getData(x,y,z)
- return data[y + z*width + x*length*width + 1]
- end
- function readbytes(h, n)
- for i=1,n do
- h.read()
- end
- end
- function readname(h)
- local n1 = h.read()
- local n2 = h.read()
- if(n1 == nil or n2 == nil) then
- return ""
- end
- local n = n1*256 + n2
- local str = ""
- for i=1,n do
- local c = h.read()
- if c == nil then
- return
- end
- str = str .. string.char(c)
- end
- return str
- end
- function parse(a, h, containsName)
- local containsName = containsName or true
- local i,i1,i2,i3,i4
- if a==0 then
- return
- end
- if containsName then
- name = readname(h)
- uPrint(name,colors.lime,1)
- end
- if a==1 then
- readbytes(h,1)
- elseif a==2 then
- i1 = h.read()
- i2 = h.read()
- i = i1*256 + i2
- uPrint(i,colors.white,2)
- if(name=="Height") then
- height = i
- elseif (name=="Length") then
- length = i
- elseif (name=="Width") then
- width = i
- end
- elseif a==3 then
- readbytes(h,4)
- elseif a==4 then
- readbytes(h,8)
- elseif a==5 then
- readbytes(h,4)
- elseif a==6 then
- readbytes(h,8)
- elseif a==7 then
- i1 = h.read()
- i2 = h.read()
- i3 = h.read()
- i4 = h.read()
- i = i1*256*256*256 + i2*256*256 + i3*256 + i4
- if name == "Blocks" then
- for i=1,i do
- table.insert(blocks, h.read())
- end
- saveTable(blocks, "blocks")
- elseif name == "Data" then
- for i=1,i do
- table.insert(data, h.read())
- end
- saveTable(data,"data")
- else
- readbytes(h,i)
- end
- elseif a==8 then
- i1 = h.read()
- i2 = h.read()
- i = i1*256 + i2
- readbytes(h,i)
- elseif a==9 then
- --readbytes(h,5)
- local type = h.read()
- i1 = h.read()
- i2 = h.read()
- i3 = h.read()
- i4 = h.read()
- i = i1*256*256*256 + i2*256*256 + i3*256 + i4
- for j=1,i do
- parse(h.read(), h, false)
- end
- end
- end
- function readThrough()
- local a = 0
- while (a ~= nil) do
- a = h.read()
- parse(a, h)
- end
- end
- function saveTable(tData,sFilename)
- local h = fs.open(sFilename,"w")
- h.write(textutils.serialize(tData))
- h.close()
- end
- uPrint = function(sTitle,nColor,nIndents)
- --reads a number, string, or payload
- sTitle = sTitle or ""
- if sTitle == "Schematic" then
- nIndents = 0
- nColor = colors.orange
- end
- nColor = nColor or colors.white
- term.setTextColor(nColor)
- nIndents = nIndents or 1
- local sIndent = ""
- for i = 1,nIndents do
- sIndent = sIndent.." "
- end
- print(sIndent..tostring(sTitle))
- end
- readThrough()
- print("Press key to start building...")
- read()
- chickenSM = nil
- chickenSM = Schematic.new()
- chickenSM.boundary.x = height-1
- chickenSM.boundary.y = width-1
- chickenSM.boundary.z = length-1
- chickenSM:recordInventory()
- --chickenSM:resetPosition()
- while true do
- --making it skip 0,0,0 (test with tent)
- blockID = getBlockId(chickenSM.target.x,chickenSM.target.y,chickenSM.target.z)
- blockData = getData(chickenSM.target.x,chickenSM.target.y,chickenSM.target.z)
- if blockID ~= 0 and blockID ~= 65 and blockID ~= 96 and blockID ~= 50 then
- chickenSM:goto()
- --turning too much is annoying
- local nSlot = chickenSM:select(blockID,blockData) --return item slot
- --takes a long time, not in the class
- if not nSlot then
- error("Not enough "..tostring(blockID)..":"..tostring(blockData))
- end
- turtle.select(nSlot)
- chickenSM:place()
- end
- chickenSM:iterateZ()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement