Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Title: HomeMaker
- Author: IceMonkee
- Description: Night is falling and you don't have shelter!
- But you do have a turtle and a bunch of blocks you
- picked up... It's time to use your turtle to
- build a shelter!
- Place any placable block materials in the turtle's
- inventory and make sure there is enough fuel.
- Then run the program supplying the length, width, and height
- of your shelter. For the time being, shelters do not have doors,
- windows and will have a roof if you have enough materials.
- --]]
- function message( msg )
- print(msg)
- end
- function checkFuelLevel()
- if turtle.getFuelLevel() < 100 then
- turtle.select(16)
- while turtle.getItemCount() == 0 do
- message("Please place fuel in slot 16!")
- sleep(5)
- end
- turtle.select(1)
- end
- end
- function selectMaterials()
- if turtle.getItemCount() == 0 then
- foundItems = false
- while foundItems == false do
- for i=1,16 do
- turtle.select(i)
- if turtle.getItemCount() > 0 then
- turtle.select(i)
- foundItems = true
- break
- end
- end
- if foundItems == false then
- print("Please insert building materials!")
- end
- sleep(1)
- end
- end
- end
- args = { ... }
- args[1]=tonumber(args[1])
- args[2]=tonumber(args[2])
- args[3]=tonumber(args[3])
- depth = args[1]
- width = args[2]
- height = args[3]
- turtle.up()
- for i=1,height do
- for j=1,depth do
- selectMaterials()
- turtle.placeDown()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- end
- turtle.turnRight()
- for j=1,width do
- selectMaterials()
- turtle.placeDown()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- end
- turtle.turnRight()
- for j=1,depth do
- selectMaterials()
- turtle.placeDown()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- end
- turtle.turnRight()
- for j=1,width do
- selectMaterials()
- turtle.placeDown()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- end
- turtle.turnRight()
- while turtle.up() == false do
- turtle.attackUp()
- turtle.digUp()
- end
- end
- --Now add the roof
- for i=1,width+1 do
- for j=1,depth do
- selectMaterials()
- turtle.placeDown()
- while turtle.forward() == false do
- turtle.attack()
- turtle.dig()
- end
- end
- if (i % 2) == 1 then
- turtle.turnRight()
- selectMaterials()
- turtle.placeDown()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- selectMaterials()
- turtle.placeDown()
- turtle.turnRight()
- else
- turtle.turnLeft()
- selectMaterials()
- turtle.placeDown()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- selectMaterials()
- turtle.placeDown()
- turtle.turnLeft()
- end
- end
- for i=1,height do
- while turtle.down() == false do
- turtle.digDown()
- turtle.attackDown()
- end
- end
- message("Shelter Complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement