Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("libstruct")
- b=libstruct
- a=aware
- args = {...}
- if #args < 1 then
- error("Arguments: <name>")
- end
- t=b.load(args[1]..".3d")
- height=t["height"]
- width=t["width"]
- depth=t["depth"]
- height=((height+1)*2)-1
- width=((width+1)*2)-1
- depth=((depth+1)*2)-1
- endblock=t["endblock"]
- parwidth=(width %2 == 0) -- width er partall
- moveleft=true
- a.setposition("start")
- function refill(r)
- if r == nil then
- print("refill got r == nil")
- return
- end
- if r == 0 then return end
- if turtle.getItemCount(r) > 5 then return end
- if not (endblock==16) then
- turtle.select(r)
- print("Looking for " .. r .. " from " .. endblock+1 .. " to 16")
- for i=endblock+1,16 do
- if turtle.compareTo(i) then
- print("Found in " .. i)
- turtle.select(i)
- turtle.transferTo(r)
- free=turtle.getItemSpace(r)
- turtle.select(r)
- if free == 0 then
- print("free == 0 ")
- break
- end
- else
- print(r .. " was not in " .. i)
- end
- end
- end
- if turtle.getItemCount(r) <= 5 then
- print("--Sleeping while waiting for refill for slot " .. r)
- while (turtle.getItemCount(r) <= 5) do
- os.sleep(15)
- end
- end
- end
- function line()
- print("Building line")
- for d=0,depth do
- pos = a.getposition("current")
- print("Pos: h" .. pos[3]*-1 .. "-w" .. pos[1] .. "-d" .. pos[2])
- block = t[math.floor((pos[3]*-1)/2)][math.floor(pos[1]/2)][math.floor(pos[2]/2)]
- refill(block)
- b.place(block)
- if(d<depth) then
- a.df()
- end
- end
- end
- function turn()
- if(moveleft) then
- print("Moving left")
- a.l()
- a.df()
- a.l()
- else
- print("Moving right")
- a.r()
- a.df()
- a.r()
- end
- moveleft = not moveleft
- end
- function layer()
- print("Building layer")
- for w=0,width do
- line()
- if(w<width) then
- turn()
- end
- end
- end
- -- we build from the bottom up
- for h=0,height-1 do
- a.dd()
- end
- for h=0,height do
- layer()
- if not (h == height) then
- a.du()
- b.t180()
- if parwidth then
- if h%2 == 0 then
- turnleft=false
- else
- turnleft=true
- end
- else
- turnleft=true
- end
- end
- end
- print("Finised, going home")
- a.goto(a.getposition("start"))
- b.awarecleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement