This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Jappards's profile picture

[arguments]fortress walls: mining turtle

Started by Jappards, 11 April 2013 - 07:09 AM
Jappards #1
Posted 11 April 2013 - 09:09 AM
this is a program that makes walls with a platform on them:
Spoiler

code:
Spoiler

local tArgs= {...}

function placeDown()
turtle.place()
turtle.up()
end
function linewall()
placeDown()
placeDown()
turtle.placedown()
turtle.forward()
turtle.forward()
turtle.placeDown()
turtle.up()
turtle.placeDown()
end
function fiveDown()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
end
function Return()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
fiveDown()
turtle.back()
turtle.back()
turtle.back()
end
function returnWall()
linewall()
Return()
end

for i= 1,tonumber(tArgs[1]) do
returnWall()
print("done") --optional
end

Note: this program is very manual.

how to use:
  1. fill the first slot with the building material.
  2. run the program with a space and the amount of blocks in length the wall needs to be.
cogilv25 #2
Posted 15 April 2013 - 02:39 PM
make it build the whole fortress and I might try it ;)/>
superaxander #3
Posted 15 April 2013 - 07:25 PM
In the end the

for i=1, tArgs do
Should be

for i=1, tonumber(tArgs[1]) do
Because the arguments are put in a table and are not just plainly stored

EDIT: I messed the bb-code up it's fixed now
Jappards #4
Posted 16 April 2013 - 06:00 AM
that bug is fixed. thanks for noticing it me.

@cogilv25: ok, but i first begin with making an square wall that has corners, but for the building inside the walls, i need to use my building API for that.
Jappards #5
Posted 17 April 2013 - 09:10 AM
i am doing the corners now, on some sort of way it was really messed up, going to fix that tommorrow.
Jappards #6
Posted 18 April 2013 - 06:03 AM
here is some alpha (doesn`t work yet) code:
Spoiler

function placeDown(hight)
for i=1,hight do
  turtle.place()
  turtle.up()
end
end
function linewall()
placeDown(3)
turtle.placeDown()
turtle.forward()
turtle.forward()
turtle.placeDown()
turtle.forward()
turtle.placeDown()
turtle.up()
turtle.placeDown()
end
function down(hight)
for i=1,hight do
  turtle.down()
end
end
function Return()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
down(5)
turtle.back()
turtle.back()
turtle.back()
end
function returnWall()
linewall()
Return()
end
function wallLine(length)
for i= 1,length do
  returnWall()
  print("done")
end
end
function cornerPiece(line)
for i=1,line do
  placeDown(3)
  down(3)
  turtle.turnLeft()
  turtle.forward()
  turtle.turnRight()
  placeDown(3)
end
end
function cornerEdge(width)
for i=1,width do
  turtle.forward()
  turtle.forward()
  turtle.placeDown()
  turtle.forward()
  turtle.placeDown()
  turtle.up()
  turtle.placeDown()
  turtle.back()
  turtle.back()
  turtle.down()
  turtle.turnLeft()
  turtle.forward()
  turtle.turnRight()
end
end
function corner()
cornerPiece(3)
turtle.turnLeft()
turtle.back()
cornerPiece(2)
cornerEdge(3)
turle.placeDown()
turtle.forward()
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.place()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.place()
turtle.back()
turtle.back()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
cornerEdge(3)
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.placeDown()
turtle.turnLeft()
turtle.forward()
turtle.placeDown()
turtle.turnLeft()
turtle.forward()
down(3)
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.forward()
end
function walls()
wallLine(20)
corner()
wallLine(20)
corner()
wallLine(20)
corner()
end
walls()
cogilv25 #7
Posted 20 April 2013 - 11:45 AM
this doesn't work he places a block then turns left and right <- Sorry if that seems negative :)/>

p.s. your code is quite messy you might want to indent your code and space it out a bit :)/>

p.s.s. a technique to make your code shorter is to look for repeating patterns and use loops instead :)/>

Hope this helps you :)/>

EDIT: Sorry I didn't see your (doesn't work yet) lol
unobtanium #8
Posted 20 April 2013 - 12:34 PM
Dont forget to refuel the turtle ;D
Jappards #9
Posted 20 April 2013 - 09:57 PM
that code (post #6) is in alpha right now, i am working on fixing it, i just post it for others to review if they wanted to, thanks for reporting the bugs :)/>.