Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dom = "http://tools.cablepost.co.uk"
- --Turtle AutoBuilder v0.2
- --Created by pokemonmegaman, 2012
- --Uses files from BINVOX to create 3D models in game
- --Better put alot of materials in this, because it uses a TON.
- --
- --Changelog
- --v0.3: Turtle now returns to ground if it needs materials
- --v0.2.1: Reversed build direction to stop mirroring, as well as future development
- --v0.2: Stopped turtle from going up if there are no blocks to place, reducing build time signifigantly
- --v0.1: Initial release
- --there are also a couple of mods by BillBodkin
- local arg = { ... }
- local model = arg[1]
- local content = http.get(dom .. "/cc/binvox/" .. model).readAll()
- if not content then
- error("Could not connect to website")
- end
- f = fs.open(model, "w")
- f.write(content)
- f.close()
- --Declarations
- local x = 0
- local y = 0
- local z = 0
- local turtlex = 0
- local turtley = 0
- local turtlez = 0
- local size = {}
- local file = io.open(model, "r")
- local s = file:read("*l")
- local sizestr = file:read("*l")
- local line = nil
- local blockarray = {}
- --Gets size of model
- for k, v in string.gmatch(sizestr, "%d+") do
- size = tonumber(k)
- end
- --We do this to move the "cursor" to the data
- s = file:read("*l")
- s = file:read("*l")
- s = file:read("*l")
- --And now we parse the file, line by line.
- while x < size do
- while y < size do
- line = file:read("*l")
- a = 0
- for k in line:gmatch('%d+') do --Dumps line into an array
- a = a + 1
- blockarray[a] = k
- end
- while z < size do
- z = z + 1
- if blockarray[z] == "1" then
- while turtlez < z do
- turtle.up()
- turtlez = turtlez + 1
- end
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- if i == 16 then
- print("Please reload me with more items! (Press enter when done.)")
- io.read()
- turtle.select(1)
- else
- turtle.select(i+1)
- end
- else
- turtle.place()
- end
- end
- --turtle.place()
- if turtle.getItemCount(16) == 0 then
- local k = 0
- while turtle.detectDown() == false do
- k = k + 1
- turtle.down()
- end
- print("Please reload me with more items! (Press enter when done.)")
- --io.read()
- while k > 0 do
- turtle.up()
- k = k - 1
- end
- end
- end
- end
- turtle.back()
- y = y + 1
- while turtlez > 0 do
- turtle.down()
- turtlez = turtlez - 1
- end
- z = 0
- end
- turtle.turnLeft()
- turtle.back()
- x = x + 1
- turtle.turnRight()
- while y > 0 do
- turtle.forward()
- y = y - 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement