7 posts
Posted 08 June 2014 - 04:08 AM
http://pastebin.com/CL9yaAFRI don't know if anyone plays
MineColonies, but they're currently working on the next big release. Currently, building watchtowers and walls are kind of funky, especially walls. So I thought a turtle could do much better. And it can. :)/>
The big challenge was getting the movement right so that the turtle could create a new wall directly next to another and move to the point so that it's primed and ready to go for another. When building the first section, you'll have to make sure that the turtle is 1 space off the ground. If you use a disk drive it's recommended that you place it on the right. You'll have to remove it once the turtle gets going.
The dimensions for one section of a wall are 6L, 3W, 6H. It builds out and left from the starting point.
Resources Needed (1 Section):
- Slot 1 = 16 Wooden Planks
- Slot 2 = 18 Cobblestone
- Slot 3 = 12 Wood
- Slot 4 = 2 Torches
- Slot 5 = 3 Ladders
I didn't give an option to build multiple walls at once, if you'd like to add that all you have to do is turn the bottom portion of the code into a function and loop it.
I tried to comment the code for quick reading. I appreciate any feedback and if you make any edits let me know, I'd love to see them! ;)/>
[
Picture of Expanded Wall] (Large)
http://pastebin.com/CL9yaAFR
23 posts
Posted 18 June 2014 - 05:28 AM
Spoiler
function placeBlock(n) -- Place block below, move forward
for i = 1,n do
turtle.placeDown()
turtle.forward()
end
end
function turnAround() -- 180 deg turn
turtle.turnLeft()
turtle.turnLeft()
end
function backUp(n) -- Move back n times
for i = 1,n do
turtle.back()
end
end
function forward(n) -- Move forward n times
for i = 1,n do
turtle.forward()
end
end
function down(n) -- Move down n times
for i = 1,n do
turtle.down()
end
end
function planks()
turtle.select(1) -- Wood Plank: 16 per section
placeBlock(6) -- Place 6 wood planks
for i = 1,2 do -- Moves to second row
turtle.turnLeft()
turtle.forward()
end
placeBlock(6) -- Places second plank row
end
function cobblestone()
turtle.select(2) -- Cobblestone: 18 per section
turtle.up() -- Up and around to place new row on top
turnAround()
placeBlock(6) -- Uses place/forward pattern, loop not possible
turtle.up()
turnAround()
turtle.forward() -- Extra forward to account for place/forward pattern
placeBlock(6)
turtle.up()
turnAround()
placeBlock(6)
end
function plankEdge()
turtle.turnLeft() -- Move up and left for spider blocker
turtle.forward()
turtle.turnLeft()
turtle.up()
turtle.select(1) -- Wood Plank: 16 per section
for i = 1,4 do -- Old forward/place pattern (works here)
turtle.forward()
turtle.placeDown()
end
end
function pillars()
turtle.select(3) -- Wood: 12 per section
turtle.forward()
down(5) -- Start building from bottom
for i = 1,6 do
turtle.up()
turtle.placeDown()
end
backUp(2) -- Get to spot to place torch
turtle.down()
turtle.select(4) -- Torch: 2 per section
turtle.place()
turtle.up() -- Move to next pillar
forward(3)
down(6)
turtle.select(3) -- Wood: 12 per section
for i = 1,6 do
turtle.up()
turtle.placeDown()
end
forward(2) -- Move to second torch
turnAround()
turtle.down()
turtle.select(4) -- Torch: 4 per section
turtle.place() -- Place 2nd torch
end
function ladders()
turtle.turnRight() -- Move to position for ladders
forward(3)
turtle.turnLeft()
forward(2)
turtle.turnLeft()
down(2)
turtle.select(5) -- Ladder: 3 per section
for i = 1,3 do -- Place ladders
turtle.place()
turtle.down()
end
end
function moveNext()
turtle.up() -- Move into position for next section (perfect fit!)
turtle.turnRight()
forward(5)
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.forward()
end
--[[Computer Craft Castle Wall (Minecolonies)(In Progress)]]--
--[[Start turtle one space off ground, disk drive to right]]--
--[[Remove disk drive after starting if using]]--
local function singleWall()
planks()
turtle.forward()
cobblestone()
plankEdge()
pillars()
ladders()
moveNext()
end
term.clear()
term.setCursorPos(1,1)
print("How many walls do you want built")
x = read()
for i =1, x do
singleWall()
end
Of course this wont work indefinitly you need to give it materials but if youre constantly giving it materials you can work on something else
Edited on 18 June 2014 - 04:24 PM
23 posts
Posted 18 June 2014 - 05:39 AM
oh and also, disk drives are unecesary we have pastebin :P/> "pastebin get CL9yaAFR walls"
3 posts
Posted 22 June 2014 - 06:08 PM
Great Program. But there something a little off in it. I have tried several times to get it to work and it seems to offset the wall as gets towards the top of the wall.
I make sure it is one space off the ground before it starts.
7 posts
Posted 22 June 2014 - 08:14 PM
oh and also, disk drives are unecesary we have pastebin :P/> "pastebin get CL9yaAFR walls"
Sure, I like to save my programs so I don't have to constantly reload them. :)/>
I make sure it is one space off the ground before it starts.
This is mentioned in the post above.
3 posts
Posted 22 June 2014 - 09:43 PM
Sorry I must be missing something as I don't see a post addressing the problem of the top part of the wall offsetting.