Jump to content




petrus4's scripts


2 replies to this topic

#1 petrus4

  • New Members
  • 21 posts

Posted 12 March 2012 - 05:11 AM

Hey everyone,
Added a few more tiny scripts now. The first one is a parallel (that is, four turtles building simultaneously) wall-building script, to serve as the basis for a house. It only builds the walls at the moment, because I haven't figured out how to write a multi-bot roof building script without having to manually pick up the turtles and move them to the right place at the top of the walls, and I know most of you probably aren't interested in doing that. Maybe someone who is better at this than me, can figure out how to do that, if you want to use this as the basis of something else.

For this you'll need five wireless mining turtles (the four builders, and a fifth to activate the script on the other four via rednet) and half a stack (32 blocks, or actually 24 to be exact) of building material (I just use cobble, but I know most people like wood) per turtle.

Because the walls are six blocks in length, I manually place the first turtle on the first block where the house will be built, and then each turtle on the sixth block, each facing 90 degrees away from each other. So the first turtle faces forward. The second turtle faces right, and is on the sixth block forward from the first turtle. The third turtle faces backwards, and is on the sixth block to the right of the second turtle. The fourth turtle faces left, and is on the sixth block to the right of the first turtle. The fifth turtle can be placed anywhere, as long as it is within 50 blocks of the four builders, and doesn't get in the way. Buildwall is run on the four turtles which sets them listening, when you put the cobble in their inventories, and rednet-send is run on the fifth turtle, in order to get them all building.

Here's the script:-

buildwall:-

function tworows()
turtle.up()
for i=1,5 do
turtle.placeDown()
turtle.forward()
end
turtle.placeDown()
turtle.up()
turtle.placeDown()
for i=1,5 do
turtle.back()
turtle.placeDown()
end
end

function wall()
for i=1,2 do
tworows()
end
end

rednet.open("right")
id, message = rednet.receive()
print ("Computer ".. id .. " has sent us a message")
print ("The message is")
print (message)
wall()

rednet-send:-
rednet.open("right")
rednet.broadcast("hello")

I'm aware that this is very rough, but one advantage is that once you get the hang of the placement, it's fast. The end result is the basis for a 4x4 (internal) structure, and adding the roof manually yourself is quick as well. I know there are other house builders out there which are complete, but I haven't seen any others yet that use more than one turtle, either. If you have a lot of wireless mining turtles, you could also build several of these simultaneously, and potentially give yourself an entire (large) base in under 15 minutes or so.

#2 petrus4

  • New Members
  • 21 posts

Posted 14 March 2012 - 07:23 AM

Another script here; my very basic tree planting script. Although there's minimal obstacle recovery, this is also parallel friendly; you can line up multiple turtles at the appropriate intervals (four blocks) and use the usual rednet-send script to get them all running at once. These two functions both need items in the turtle's inventory; basic planting (which assumes dirt blocks and torches are already placed) only requires saplings in slot one. The fromscratch function, which adds dirt, torches, and trees, requires 14 torches in slot 9, dirt blocks in slot 8, and saplings in slot 7.

function treeplant()
turtle.place()
	if turtle.detectUp() then
	turtle.digUp()
	end
turtle.up()
for i=1,4 do
	if turtle.detect() then
	turtle.dig()
	end
turtle.forward()
end
turtle.down()
end

function fullrow()
	for i=1,14 do
	treeplant()
	end
end

function fromscratch()
	if turtle.detectUp() then
	turtle.digUp()
	end
turtle.up()

for i=1,14 do
	turtle.select(9)
	turtle.placeDown()
		if turtle.detect() then
		turtle.dig()
		end
	turtle.forward()
	turtle.select(8)
	turtle.placeDown()
	turtle.up()
	turtle.select(7)
	turtle.placeDown()
		for i=1,3 do
		turtle.forward()
		end
	turtle.down()
end
end

rednet.open("right")
id, message = rednet.receive()
print ("Computer ".. id .. " has sent us a message")
print ("The message is")
print (message)
if message == "fullrow" then
fullrow()
elseif message == "fromscratch" then
fromscratch()
end

rednet-send script:-

rednet.open("right")
rednet.broadcast("fullrow")

Run rednet-send on a seperate controller turtle, or a computer, once you've loaded your other turtles with the necessary items, and have run the treeplant script in order to make them listen.

#3 petrus4

  • New Members
  • 21 posts

Posted 14 March 2012 - 07:34 AM

This one is an obsidian farming script. When I come across a large lava lake, I douse it with water, place a turtle at one edge of it, and then run this. It will cut one 6x12 layer of obsidian, at which point I will then generally have to pour water on the next layer. It's great for farming a few quick stacks of obsidian, though, and you could definitely use it for other things, including bridge building, if you replaced turtle.dig() with turtle.place().

function minerow()
    for i=1,3
    do
    turtle.digDown()
    turtle.forward()
    end
end

function newline()
    for i=1,3
    do
    turtle.back()
    end
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end

function segment()
    for i=1,6
    do
    minerow()
    newline()
    end
end

function newseg()
turtle.turnLeft()
    for i=1,6 do
    turtle.forward()
    end
    turtle.turnRight()
    for i=1,3 do
    turtle.forward()
    end
end

for i=1,2 do
segment()
newseg()
end






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users