Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --House builder
- --Logan Eastman
- local length = 5; --Internal length of building
- local width = 7; --Internal width of building
- local height = 1; --Internal height; does not include ceiling
- local itemSlot = 1;
- local fuelSlot = 16;
- function checkResources()
- --Check fuel
- local fuelThreshold = 2
- if(turtle.getFuelLevel() < fuelThreshold) then
- if(turtle.getItemCount(fuelSlot)>0) then
- turtle.select(fuelSlot)
- turtle.refuel(1)
- turtle.select(itemSlot)
- end
- end
- --Check Items
- if(turtle.getItemCount(itemSlot) == 0) then
- if((itemSlot+1) ~= fuelSlot) then
- itemSlot = itemSlot+1
- if(itemSlot >= 16) then
- if(fuelSlot ~= 1) then
- itemSlot = 1
- else
- itemSlot = 2
- end
- end
- turtle.select(itemSlot)
- else
- if(fuelSlot == 16) then
- itemSlot = 1
- else
- itemSlot = itemSlot + 2
- end
- turtle.select(itemSlot)
- end
- if(turtle.getItemCount(itemSlot) == 0) then
- print "All out of items"
- end
- end
- end
- function buildWalls()
- for floor = 1,height,1 do --Loop for every block height of building
- checkResources()
- turtle.up() --Move up
- for i = 1,2,1 do --repeat twice per block height
- for side = 0,length,1 do --Forward for length
- checkResources()
- turtle.placeDown() --Place blocks
- turtle.forward() --Move forward
- end
- turtle.turnLeft()
- for side = 0,width,1 do --forward for width
- checkResources()
- turtle.placeDown() --place blocks
- turtle.forward() --Move forward
- end
- turtle.turnLeft()
- end
- end
- end
- function buildCeiling()
- local rightTurn = true
- checkResources()
- turtle.up()
- for w = 0,width+1,1 do --Loop for every block height of building
- if(rightTurn) then --switch rightTurn toggle
- rightTurn = false
- else
- rightTurn = true
- end
- for side = 0,length,1 do --Forward for length
- checkResources()
- turtle.placeDown() --Place blocks
- turtle.forward() --Move forward
- end
- if(rightTurn) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- turtle.placeDown() --Place block before moving
- checkResources()
- turtle.forward() --Move forward
- if(rightTurn) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- buildWalls()
- buildCeiling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement