Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t = turtle
- local c = true
- write("Lunghezza lato: ")
- local square = tonumber(read())
- local gira = "right"
- write("Altezza: ")
- local altezza = tonumber(read())
- altezza = altezza + 1 -- Aumento di 1 perché piazzo blocchi anche a livello pavimento
- local lati = 4 -- Lati del quadrato
- local slot = 16
- local function selectSlot(n)
- c = 1
- for i = 1,n do
- if turtle.getItemCount(c) == 0 then
- c = c + 1
- if c == 17 then
- print("Materiali finiti. In attesa di essere rifornita di materiali. Il controllo ripartira' tra 10 secondi")
- c = 1
- i = 1
- sleep(10)
- end
- turtle.select(c)
- end
- end
- end
- local function piazza(n)
- selectSlot(slot)
- for i = 1,n do
- selectSlot(slot)
- t.dig()
- t.forward()
- t.digDown()
- t.placeDown()
- end
- end
- local function lato(n)
- selectSlot(slot)
- n = n + 1
- for i = 1,n do
- selectSlot(slot)
- t.digDown()
- t.placeDown()
- t.dig()
- t.forward()
- end
- end
- while c do
- selectSlot(slot)
- -- Pavimentazione
- for i2 = 1,square do
- piazza(square)
- t.dig()
- t.forward()
- if gira == "right" then
- t.turnRight()
- t.dig()
- t.forward()
- t.turnRight()
- gira = "left"
- else
- t.turnLeft()
- t.dig()
- t.forward()
- t.turnLeft()
- gira = "right"
- end
- end
- -- Lato
- for i5 = 1,altezza do
- for i4 = 1,lati do
- lato(square)
- if gira == "right" then -- deve cambiare senso
- t.turnLeft()
- else
- t.turnRight()
- end
- end
- if i5 == altezza then
- t.back()
- for i = 1,altezza-1 do
- t.digDown()
- t.down()
- end
- if gira == "right" then -- deve cambiare senso
- t.turnLeft()
- else
- t.turnRight()
- end
- for i = 1,square do
- t.dig()
- t.forward()
- end
- if gira == "right" then
- t.turnRight()
- else
- t.turnLeft()
- end
- else
- t.digUp()
- t.up()
- end
- end
- c = false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement