--[[ Auflistung Materialien: 01 Fußboden innen: 12 02 Fußboden Veranda: 0 03 Halfsteps: 4 04 Sockel: 14 05 Wände Typ 1: 22 06 Wände Typ 2: 0 07 Fenster: 8 08 Türen: 0 09 Trittplatte: 0 10 Craftingtable: 1 11 Truhen: 0 12 Fackeln: 9 13 Öfen: 0 14 Dach: 38 15 Dach: 0 16 Giebel: 0 Minecraft Turtle: Simple House 2013-12-13 (c) psychedelixx / thebiglebowski33 Builds a simple house Usage: - use turtle and type "label set " (to give your turtle an unique name so it remembers its programs) - type "pastebin get jQ7H0UJd house" --]] --[[ --- Konstanten --- ]]-- dirCounter = 1 countList={} keyFloorIn = "1" keyFloorOut = "2" halfSteps = "3" keySocket = "4" keyWalls1 = "5" keyWalls2 = "6" keyWindows = "7" keyDoors = "8" keyPressPlate = "9" keyCraftTable = "10" keyChests = "11" keyTorches = "12" keyFurnaces = "13" keyRoof1 = "14" keyRoof2 = "15" keyGable = "16" countList[keyFloorIn] = 12 countList[keyFloorOut] = 0 countList[halfSteps] = 4 countList[keySocket] = 14 countList[keyWalls1] = 22 countList[keyWalls2] = 0 countList[keyWindows] = 8 countList[keyDoors] = 0 countList[keyPressPlate] = 0 countList[keyCraftTable] = 1 countList[keyChests] = 0 countList[keyTorches] = 9 countList[keyFurnaces] = 0 countList[keyRoof1] = 38 countList[keyRoof2] = 0 countList[keyGable] = 0 --[[ for key, value in pairs(countList) do print (key, " = " , value) end ]]-- --[[ --- Parameter ---- ]]-- local args = { ... } if #args < 1 then print("") end --[[arg1 = tonumber(args[1])]]-- --[[ --- Item Check --- ]]-- function enoughResources() for key, value in pairs(countList) do if turtle.getItemCount(tonumber(key)) < value then return false end end return true end function calcFuel(blueprint) return #blueprint*#blueprint[1]*#blueprint[1][1] end function turn() if dirCounter%2 == 1 then t.right() t.forward() t.right() else t.left() t.forward() t.left() end dirCounter = dirCounter + 1 end function buildHouse(blueprint) t.up() yMax = #blueprint y = 1 while y <= #blueprint do zMax = #blueprint[y] z = 1 while z <= zMax do xMax = #blueprint[y][z] if dirCounter%2 == 1 then x = 1 else x = xMax end while (x <= xMax and dirCounter%2 == 1) or (x >= 1 and dirCounter%2 == 0) do slot = blueprint[y][z][x] print("x: ", x, "/", xMax, " - ", "z: ", z, "/", zMax, " - ", "y: ", y, "/", yMax, " - ", "slot: ", slot) if slot > 0 then if turtle.getItemCount(slot) == 0 and slot == 14 then slot = 15 end if slot == 13 then t.left() end t.placeDown(slot) if slot == 13 then t.right() end end if (x < xMax and dirCounter%2 == 1) or(x > 1 and dirCounter%2 == 0) then t.forward() end if dirCounter%2 == 1 then x = x+1 else x = x-1 end end if z < zMax then turn() end z = z+1 end if y < yMax then driveToStartPos(blueprint, y) else t.forward() for y = 1, yMax, 1 do t.down() end print("Finished!") print("All your base are belong to us") end y = y+1 end end --[[ Funktion Rückfahrt: ]]-- function driveToStartPos(array, y) print("Driving to start position") if dirCounter%2 == 0 then t.right() else t.right() t.right() for x = 1, #array[y][#array[y]]-1, 1 do t.forward() end t.right() end for z = 1, #array[y]-1, 1 do t.forward() end t.right() t.up() dirCounter = 1 end function start() if enoughResources() or 1 == 1 then print("forwards, to the moon, alice") layer = {} layer[1] = {{ 0,12, 4, 4, 4,12}, { 3, 4, 1, 1, 1, 4}, { 3, 4, 1, 1, 1, 4}, { 3, 4, 1, 1, 1, 4}, { 3, 4, 1, 1, 1, 4}, { 0,12, 4, 4, 4,12}} layer[2] = {{ 0, 0, 5, 5, 5, 0}, { 0, 5, 0, 0, 0, 5}, { 0, 0, 0, 0, 0, 5}, { 0, 5, 0, 0, 0, 5}, { 0, 5, 10, 0, 0, 5}, { 0, 0, 5, 5, 5, 0}} layer[3] = {{ 0, 0, 5, 7, 5, 0}, { 0, 5, 0, 0,12, 5}, { 0, 0, 0, 0, 0, 7}, { 0, 5, 0, 0, 0, 7}, { 0, 5, 0, 0, 0, 5}, { 0, 0, 5, 7, 5, 0}} layer[4] = {{ 0,15,15,15,15,15}, { 0,15, 0, 0, 0,15}, { 0,15, 0, 0, 0,15}, { 0,15, 0, 0, 0,15}, { 0,15, 0, 0, 0,15}, { 0,15,15,15,15,15}} layer[5] = {{ 0, 0, 0, 0, 0, 0}, { 0,15,15,15,15,15}, { 0, 7, 0, 0, 0, 7}, { 0, 7, 0, 0, 0, 7}, { 0,15,15,15,15,15}, { 0, 0, 0, 0, 0, 0}} layer[6] = {{ 0, 0, 0, 0, 0, 0}, { 0,12, 0, 0, 0,12}, { 0,15,15,15,15,15}, { 0,15,15,15,15,15}, { 0,12, 0, 0, 0,12}, { 0, 0, 0, 0, 0, 0}} if turtle.getFuelLevel() < calcFuel(layer) then print("Amount of missing fuel: ", calcFuel(layer)-turtle.getFuelLevel()) print("Missing fuel in coal: ", calcFuel(layer)-turtle.getFuelLevel()/80+1) print("Fill fuel in slot 1, type 'refuel ' and try again") error() end buildHouse(layer) else print("Not enough Resources") end end print("======== 2013 (c) psy & lebo ==========") print("======== Simple House Builder =========") start()