Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This program will allow a turtle to build a wall,
- -- you must give the turtle enough blocks to build the wall.
- -- Usage: wall.lua length height
- input = {...}
- Largeur = tonumber(input[1])
- Longueur = tonumber(input[2])
- -- The starting slot to look for building materials (from left to right, top to bottem)
- --ie. 1 2 3
- -- 4 5 6
- -- 7 8 9
- currentSlot = 2
- -- This is a function, it is peice of script that we will run later.
- -- If this inventory slot runs out of building blocks, move to the next slot.
- function checkFuel(currentSlot)
- if turtle.getFuelLevel() <= 100 then
- if turtle.getItemCount(1) == 0 then
- print("Out of fuel.")
- exit()
- else
- turtle.select(1)
- turtle.refuel(1)
- turtle.select(currentSlot)
- end --if
- end --if
- end --checkFuel()
- function gotoNextSlotIfEmpty()
- if turtle.getItemCount(currentSlot) == 0 then
- currentSlot = currentSlot + 1
- turtle.select(currentSlot)
- end
- end
- -- This is where the code starts running.
- turtle.select(currentSlot)
- for la = 1, Largeur do
- for lo = 1, Longueur do
- checkFuel(currentSlot)
- turtle.placeDown()
- gotoNextSlotIfEmpty() -- This call runs the function above, functions must be placed above where they are used.
- if lo ~= Longueur then -- ~= means 'not equal'
- turtle.forward()
- end
- end
- -- retour
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- for lo = 1, Longueur do
- turtle.placeDown()
- gotoNextSlotIfEmpty() -- This call runs the function above, functions must be placed above where they are used.
- if lo ~= Longueur then -- ~= means 'not equal'
- turtle.forward()
- end
- end
- if la ~= Largeur/2 then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement