Posted 05 May 2013 - 03:20 AM
I've made an any size rectangular room builder which places 3 blocks when building walls. At first it wasn't too robust after but after some work I made it a little better and more newbie proof .At this point I'm turning it into an "any shape wall builder".
This script can be used with either command line argument or a basic user interface. it will always stop in a valid building position so it can be chained to build more complex buildings.
command line demo video of building a small castle using auto length/width detection:
[media]http://youtu.be/MfKGmfCgPu0[/media]
pastebin :
http://pastebin.com/ip1SPj7q
pastebin get ip1SPj7q build
dev/beta versions:
http://pastebin.com/0mqi84si
custom shape polygon test
http://pastebin.com/bxczYmxZ
parameters are 0-3 height repeat length1 halfturnL1 length2 halfturnL
the first parameter is a bit flag and when active it does a function . bit 0x1 means unconnected and bit 0x2 means start diagonal
this program doesn't turn around before building. it repeats the build length and half turn commands according to the parameter and then build another z level in the same way.
building an octagon(3 high 4 length ) is test 0 3 8 3 1 .
building a diamond is test 2 3 4 3 2Basic Features
- Builds a wall of any height with an option of a floor/roof or both(mode 0,1,2,3). It can also build platforms(use height 1 and mode 1)
- Wall building is done in an optimal path by placing 3 blocks which conserve time and fuel
- Go through contiguous slots of blocks - can be planed to make more complex looking buildings
- can build a single wall ( mode 4 )
- breaks blocks in its way (slows it down)
- setting length or width to 0 or -1 will make the turtle search for dimensions. The height must be entered. The script waits for an enter to start this (in ui mode)
-symmetric octagon building (mode 5) to build octagonal walls (I got jealous of Lancey's towers) .the length is now used as flat wall length and width is now used and diagonal wall length. unfortunately diamond tower are not posible but it's close ( length 1 gives length 2 flat walls).
-new feature hexagon tower (6) , parallelogram tower s (7) (I liked MrCrainer's Diamond towers) diagonal wall (8)
- new improvement - the turtle now keeps the correct number of blocks in its inventory regardless of obstacles
-new mechanic wall building function was rewritten to work similar to "logo" language parameters
upcoming features
- haven't started on new version - check future plans
Instructions
Place the turtle in the bottom right corner ( will place a block where it starts , builds left) ,refuel the turtle . Afterwards you should load your building materials .
For the UI just type build . In the UI enter the length ,width , height and mode(walls,walls and floor etc) .Take note the height is inclusive of the floor and roof so if you want to include both and have walls height 3 you should enter height of 5. Using height of 1 with roof/floor mode will build a plate(floor) .
The script can also accept command line parameters in the same order as the UI. Entering valid command line parameters would not prompt you. and start building immediately (will exit if not enough fuel to build). . If you enter invalid parameters the UI will be open syntax will be printed.
For automatic building size detection place the turtle ,refuel it and then place blocks a certain distance in front of the turtle and then one left of the block(the size includes those blocks) . Start the script and enter 0 to either width or length . The turtle will then prompt you to press enter to start size detection. using mode 0 include the placed blocks. If you use width and length of -1 it will build inside the border (the placement should be different for the 2nd block).
If there are obstacles on the way make sure the turtle has an empty slot when it reaches it.
Advanced instructions (build planning / use in scripts etc)
build planning:
When the turtle is done it will always return to a valid building position where you can continue the build in any way you wish.
Take note you can also use the turtle program to replace the walls but due to the fact it turns around and throw away the block to do this.Writing a front-end program
In order to use the program with another script use shell.run("build x y z m") and then move the turtle to a new starting position and call the script again.
if you want to build a pyramid for example do
You can customize the building in any way that you wish using diagonal movement like in the end of the loop.
There is still a limitation you need to consider when building plates (floor/wall) the turtle will not return to its x,y start position in this case(might add that option in the future).
Detailed features
- UI tells the user how many block each layer takes (helps planning complex looking buildings)
- The program exits when there isn't enough fuel to build the requested building. Also tells the user an estimate on the fuel required.
- warns when there aren't enough blocks to build the requested building. gives an option to fill it up in the process (blocks must still be contiguous)
- command line parameters build <length> <width> <height> <0-4>
- return to a valid start position to allow the user to build again (would allow using a front end in the future)
- prints credit to the author (LOL ;)/> didn't exist in version)
- If the turtle is blocked when backing up it will turn around and try to break it. if it fails it will wait for the obstacle to move or be removed while trying to break it contentiously.Limits
- must be pre fueled
-will not dig down a block when it fails to place (might add that) - fixed
- can't handle blocked roof - fixed
- the UI is currently horrible even though it's informative
- the end position may not have the same x,y coordinate to the start position
- inventory tracking system is simplisticmedia
-StrayMav building a 7x7x50 tube (beyond constraint ) using an older version (past broadcasts periodically deleted)
- a carefully planed 10x10x5 I made in order to replicate : 100 stone bricks for the floor (64 ,36) ,then the 24 glass, 3 stone brick, repeat that 3 more times and then place 100 clay brick for the roof.
64 36 24 3
24 3 24 3
24 3 64 36
Useful scripts that work well with the builder
universal floor/ceiling breaker ( WAs7AETY ) - This follows the floor/ceiling and break it until it hits a wall, it then turns around and continue until it hit the corner. I made this script because I wasn't satisfied with the room height I built and I didn't feel like breaking the floor/ceiling by hand.
Plans for the future:
—-
- add universal floor /roof builder
- custom shape mode - read a file
- auto resupply
- write a wall shape learner that can continue building along any wall.
- add cmd line parameter to return to initial xy position and one to return to start position.
- make the UI better
- elliptical shape builder using f(x,y) by finding best path to stay in the function . I have some preliminary code of coordinate generation is done
- general symmetrical polygons builder- pentagon/heptagon etc and maybe general triangle builder. I'll probably need to add a line drawing function (I've done this in the past in an A* path finding simulator).
- add or write a script that breaks the walls instead of building them (can be done by loading no blocks and using command line but it's slow)
- write a front end to this script to allow complex room building
- rewrite the floor builder in a way it conserves fuel
- separate planning and buildingBenchmarks:
- Block placement rates:
- 12x12x12 tank - 0.7~ block/s (85 per minute)
- single wall mode (about 90 long 12 high) 0.56~ blocks/s (107~ per minute)
- worst case = tube inside a mountain 11x11x40 (might be longer) = 2.24 seconds per block(26~ per minute) - it can handle obstacles but block replacement has a huge overhead.
- fuel use for walls is ceil(height/3) *( 2 width +2*length - 4) . For each floor/roof add width*length. example the 12x12x12 tank takes about 4* (2*12+2*12 -4) + 2*12*12 = 176 +288= 464 fuel. when making diagonal walls it's about ceil(height/3) *(2*width +4*length -4) (length is used for diagonal walls in most cases
This script can be used with either command line argument or a basic user interface. it will always stop in a valid building position so it can be chained to build more complex buildings.
command line demo video of building a small castle using auto length/width detection:
[media]http://youtu.be/MfKGmfCgPu0[/media]
pastebin :
http://pastebin.com/ip1SPj7q
pastebin get ip1SPj7q build
dev/beta versions:
Spoiler
beta version - doesn't always work (save a copy if you like it)http://pastebin.com/0mqi84si
custom shape polygon test
http://pastebin.com/bxczYmxZ
parameters are 0-3 height repeat length1 halfturnL1 length2 halfturnL
the first parameter is a bit flag and when active it does a function . bit 0x1 means unconnected and bit 0x2 means start diagonal
this program doesn't turn around before building. it repeats the build length and half turn commands according to the parameter and then build another z level in the same way.
building an octagon(3 high 4 length ) is test 0 3 8 3 1 .
building a diamond is test 2 3 4 3 2
- Builds a wall of any height with an option of a floor/roof or both(mode 0,1,2,3). It can also build platforms(use height 1 and mode 1)
- Wall building is done in an optimal path by placing 3 blocks which conserve time and fuel
- Go through contiguous slots of blocks - can be planed to make more complex looking buildings
- can build a single wall ( mode 4 )
- breaks blocks in its way (slows it down)
- setting length or width to 0 or -1 will make the turtle search for dimensions. The height must be entered. The script waits for an enter to start this (in ui mode)
-symmetric octagon building (mode 5) to build octagonal walls (I got jealous of Lancey's towers) .the length is now used as flat wall length and width is now used and diagonal wall length. unfortunately diamond tower are not posible but it's close ( length 1 gives length 2 flat walls).
-new feature hexagon tower (6) , parallelogram tower s (7) (I liked MrCrainer's Diamond towers) diagonal wall (8)
- new improvement - the turtle now keeps the correct number of blocks in its inventory regardless of obstacles
-new mechanic wall building function was rewritten to work similar to "logo" language parameters
upcoming features
- haven't started on new version - check future plans
Instructions
Place the turtle in the bottom right corner ( will place a block where it starts , builds left) ,refuel the turtle . Afterwards you should load your building materials .
For the UI just type build . In the UI enter the length ,width , height and mode(walls,walls and floor etc) .Take note the height is inclusive of the floor and roof so if you want to include both and have walls height 3 you should enter height of 5. Using height of 1 with roof/floor mode will build a plate(floor) .
The script can also accept command line parameters in the same order as the UI. Entering valid command line parameters would not prompt you. and start building immediately (will exit if not enough fuel to build). . If you enter invalid parameters the
For automatic building size detection place the turtle ,refuel it and then place blocks a certain distance in front of the turtle and then one left of the block(the size includes those blocks) . Start the script and enter 0 to either width or length . The turtle will then prompt you to press enter to start size detection. using mode 0 include the placed blocks. If you use width and length of -1 it will build inside the border (the placement should be different for the 2nd block).
If there are obstacles on the way make sure the turtle has an empty slot when it reaches it.
Advanced instructions (build planning / use in scripts etc)
build planning:
Spoiler
The turtle can create basic designs but it has a limited inventory. if you want a different floor/walls. Setting up a certain floor is trivial unless you want an outer wall frame (check next section). When building a wall frame you must first place 3*(length-2) blocks for the inner wall and then 3 blocks for the frame. You repeat the process 3 more times (use width on the 2nd and 4th time) .After you are done put in the blocks for the roof.When the turtle is done it will always return to a valid building position where you can continue the build in any way you wish.
Take note you can also use the turtle program to replace the walls but due to the fact it turns around and throw away the block to do this.
Spoiler
Due to the inherit limitation of the program it sometimes fall short in custom builds but it's still useful if you run it multiple time.In order to use the program with another script use shell.run("build x y z m") and then move the turtle to a new starting position and call the script again.
if you want to build a pyramid for example do
-- use mode 1 if you want a filled pyramid
for w=11,3,-2 do
shell.run("build "..w.." "..w.." 1 0")
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.forward()
end
turtle.placeDown()
You can customize the building in any way that you wish using diagonal movement like in the end of the loop.
There is still a limitation you need to consider when building plates (floor/wall) the turtle will not return to its x,y start position in this case(might add that option in the future).
Detailed features
Spoiler
- UI tells the user the maximum height of each building modes- UI tells the user how many block each layer takes (helps planning complex looking buildings)
- The program exits when there isn't enough fuel to build the requested building. Also tells the user an estimate on the fuel required.
- warns when there aren't enough blocks to build the requested building. gives an option to fill it up in the process (blocks must still be contiguous)
- command line parameters build <length> <width> <height> <0-4>
- return to a valid start position to allow the user to build again (would allow using a front end in the future)
- prints credit to the author (LOL ;)/> didn't exist in version)
- If the turtle is blocked when backing up it will turn around and try to break it. if it fails it will wait for the obstacle to move or be removed while trying to break it contentiously.
Spoiler
- can only build with 1024 blocks (turtle inventory space) unless the user fills it up in the process- must be pre fueled
-
- the UI is currently horrible even though it's informative
- the end position may not have the same x,y coordinate to the start position
- inventory tracking system is simplistic
-
- a carefully planed 10x10x5 I made in order to replicate : 100 stone bricks for the floor (64 ,36) ,then the 24 glass, 3 stone brick, repeat that 3 more times and then place 100 clay brick for the roof.
Spoiler
the inventory numbers should look like this64 36 24 3
24 3 24 3
24 3 64 36
Useful scripts that work well with the builder
universal floor/ceiling breaker ( WAs7AETY ) - This follows the floor/ceiling and break it until it hits a wall, it then turns around and continue until it hit the corner. I made this script because I wasn't satisfied with the room height I built and I didn't feel like breaking the floor/ceiling by hand.
Plans for the future:
Spoiler
— in beta version—-
- add universal floor /roof builder
- custom shape mode - read a file
- auto resupply
- write a wall shape learner that can continue building along any wall.
- add cmd line parameter to return to initial xy position and one to return to start position.
- make the UI better
- elliptical shape builder using f(x,y) by finding best path to stay in the function . I have some preliminary code of coordinate generation is done
- general symmetrical polygons builder- pentagon/heptagon etc and maybe general triangle builder. I'll probably need to add a line drawing function (I've done this in the past in an A* path finding simulator).
- add or write a script that breaks the walls instead of building them (can be done by loading no blocks and using command line but it's slow)
- write a front end to this script to allow complex room building
- rewrite the floor builder in a way it conserves fuel
- separate planning and building
- Block placement rates:
- 12x12x12 tank - 0.7~ block/s (85 per minute)
- single wall mode (about 90 long 12 high) 0.56~ blocks/s (107~ per minute)
- worst case = tube inside a mountain 11x11x40 (might be longer) = 2.24 seconds per block(26~ per minute) - it can handle obstacles but block replacement has a huge overhead.
- fuel use for walls is ceil(height/3) *( 2 width +2*length - 4) . For each floor/roof add width*length. example the 12x12x12 tank takes about 4* (2*12+2*12 -4) + 2*12*12 = 176 +288= 464 fuel. when making diagonal walls it's about ceil(height/3) *(2*width +4*length -4) (length is used for diagonal walls in most cases