Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- print("X,Y,and Z sizes:")
- write("X:");x=read()
- write("Y:");y=read()
- write("Z:");z=read()
- help=true
- x=tonumber(x)
- y=tonumber(y)
- z=tonumber(z)
- layers={}
- layer=1
- for i=1,z do
- layers[i]={}
- for j=1,x do
- layers[i][j]={}
- for k=1,y do
- layers[i][j][k]=" "
- end
- end
- end
- function cnt()
- local count=0
- for i=1,z do
- for j=1,x do
- for k=1,y do
- if layers[i][j][k]~=" " then
- count=count+1
- end
- end
- end
- end
- return count
- end
- function draw()
- shell.run("clear")
- term.setTextColor(colors.gray)
- term.setBackgroundColor(colors.black)
- for i=1,y do
- for j=1,x do
- term.setCursorPos(j,i)
- if layers[layer][j][i]==" " then
- write("-")
- else
- term.setBackgroundColor(colors.red)
- write(" ")
- term.setBackgroundColor(colors.black)
- end
- end
- end
- term.setTextColor(colors.white)
- scx,scy=term.getSize()
- if help then
- term.setCursorPos(1,scy-5)
- print("Layer "..layer.."/"..z)
- print(cnt().." Blocks Required")
- print("Press ~ To Copy Previous Layer")
- print("Press Tab To Clear This Layer")
- print("Press Delete To Cancel Job")
- write("Press Enter To Finish")
- else
- term.setCursorPos(1,scy-1)
- print("Layer "..layer.."/"..z)
- write(cnt().." Blocks Required")
- end
- term.setCursorPos(scx-10,scy)
- if help then
- term.setBackgroundColor(colors.lime)
- else
- term.setBackgroundColor(colors.red)
- end
- write("Toggle Help")
- term.setBackgroundColor(colors.black)
- end
- while true do
- draw()
- e,p1,p2,p3 = os.pullEvent()
- if e=="key" then
- key=p1
- if key==28 then
- break
- elseif key==13 and layer<#layers then
- layer=layer+1
- elseif key==12 and layer>1 then
- layer=layer-1
- elseif key==41 and layer>1 then
- for i=1,y do
- for j=1,x do
- layers[layer][j][i]=layers[layer-1][j][i]
- end
- end
- elseif key==15 then
- for i=1,y do
- for j=1,x do
- layers[layer][j][i]=" "
- end
- end
- elseif key==211 then
- shell.run("clear")
- print("Thanks for using TurtlePrint")
- error()
- end
- elseif e=="mouse_click" or e=="mouse_drag" then
- mx=p2
- my=p3
- if mx<x+1 and my<y+1 then
- if p1==1 then
- layers[layer][mx][my]="|"
- else
- layers[layer][mx][my]=" "
- end
- elseif mx>scx-11 and my==scy then
- help=not help
- end
- end
- end
- t=turtle
- slot=1
- function plc()
- if t.getItemCount(slot) ==0 then
- for i=1,16 do
- if t.getItemCount(i)~=0 then
- slot=i
- t.select(i)
- repeat sleep(0) until t.placeDown()
- return
- end
- end
- repeat
- local chk=false
- shell.run("clear")
- print("Out of items, please imput more")
- print("Press Enter When Done")
- read()
- for i=1,16 do
- if t.getItemCount(i)~=0 then
- chk=true
- slot=i
- t.select(i)
- end
- end
- until chk
- print("Thanks!")
- end
- repeat sleep(0) until t.placeDown()
- end
- repeat sleep(0) until t.forward()
- bc=0
- bmc=cnt()
- for i=1,z do
- shell.run("clear")
- print("Layer "..i.." of "..z)
- repeat sleep(0) until t.up()
- for j=1,x do
- for k=1,y do
- if layers[i][j][y-k+1] ~= " " then
- plc()
- bc=bc+1
- term.clearLine(2)
- term.clearLine(3)
- term.setCursorPos(1,2)
- print(bc.." blocks placed out of "..bmc)
- print("|"..string.rep("=",math.floor(bc/bmc*10))..string.rep(" ",10-(math.floor(bc/bmc*10))).."|")
- end
- if k~=y then repeat sleep(0) until t.forward() end
- end
- for k=1,y-1 do
- repeat sleep(0) until t.back()
- end
- if j~=x then t.turnRight()
- repeat sleep(0) until t.forward()
- t.turnLeft() end
- end
- t.turnLeft()
- for j=1,x-1 do
- repeat sleep(0) until t.forward()
- end
- t.turnRight()
- end
- repeat sleep(0) until t.back()
- for i=1,z do
- repeat sleep(0) until t.down()
- end
- shell.run("clear")
- print("Print Complete")
- print("Thanks for using TurtlePrint")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement