Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TURTLE BUILDER: CUBE XYLCRAFT TANK
- -- Autore: DjGiannuzz
- -- N.B. E' richiesta una Resupply Turtle ed una Resupply Station
- m = peripheral.wrap("right")
- local tArgs = { ... }
- MAX = tonumber(tArgs[1])
- function calcola()
- a=0
- b=0
- a=((MAX * MAX)*2)+((MAX-2)*4)
- b= (((MAX-2)*(MAX-2))*4)
- c= a/64
- d= a%64
- e= b/64
- f= b%64
- print("Sono richiesti " .. a .. " blocchi di materiale solido e " .. b .. " di vetro.")
- print("Che corrispondono a:")
- print(math.floor(c) .. " stack + " .. d .. " di materiale solido.")
- print(math.floor(e) .. " stack + " .. f .. " di vetro.")
- end
- function base()
- a= true
- for j=1, MAX do
- for i=1, MAX do
- turtle.placeDown()
- if turtle.getItemCount(1) <10 then
- m.resupply(1)
- end
- if i~=MAX then
- turtle.forward()
- end
- end
- if (a==true) and (j~=MAX) then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- a=false
- elseif (a==false) and (j~=MAX) then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- a=true
- end
- end
- end
- function MainCol()
- turtle.select(1)
- for i=1, MAX-1 do
- turtle.placeDown()
- if turtle.getItemCount(1) <10 then
- m.resupply(1)
- end
- if i~=MAX-1 then
- turtle.up()
- end
- end
- end
- function col()
- turtle.select(1)
- turtle.forward()
- for i=1, MAX-2 do
- turtle.down()
- end
- turtle.select(2)
- for i=1, MAX-2 do
- turtle.placeDown()
- if turtle.getItemCount(2) <10 then
- m.resupply(2)
- end
- turtle.up()
- end
- turtle.select(1)
- turtle.placeDown()
- if turtle.getItemCount(1) <10 then
- m.resupply(1)
- end
- end
- function lato()
- for i=1, 4 do
- if (MAX%2)==0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- if i==1 then
- turtle.up()
- end
- MainCol()
- for i=1, MAX-2 do
- col()
- end
- turtle.select(1)
- if i~=4 then
- turtle.forward()
- for i=1, MAX-2 do
- turtle.down()
- end
- end
- end
- end
- function tetto()
- if (MAX%2)==0 then
- turtle.turnRight()
- a= true
- else
- turtle.turnLeft()
- a=false
- end
- turtle.forward()
- turtle.select(1)
- for j=1, MAX-2 do
- for i=1, MAX-2 do
- turtle.placeDown()
- if turtle.getItemCount(1) <10 then
- m.resupply(1)
- end
- if i~=MAX-2 then
- turtle.forward()
- end
- end
- if (a==true) and (j~=MAX) then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- a=false
- elseif (a==false) and (j~=MAX) then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- a=true
- end
- end
- end
- --MAIN
- if (MAX>= 3) and (MAX<=12) then
- while not m.link() do
- sleep(5)
- print(m.getError() .. " riprovo fra 5 secondi")
- end
- shell.run('clear')
- calcola()
- print("Premi X per continuare.")
- local event, param1 = os.pullEvent()
- while param1 ~= 45 do
- local event, param1 = os.pullEvent()
- end
- m.resupply(1)
- m.resupply(2)
- turtle.up()
- base()
- lato()
- tetto()
- else
- print ("Ampiezza del Tank non valida")
- sleep(5)
- exit()
- end
- --END MAIN
Advertisement
Add Comment
Please, Sign In to add comment