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

will this work? :/

Started by Wolf9988, 16 August 2012 - 03:58 PM
Wolf9988 #1
Posted 16 August 2012 - 05:58 PM
Im out on vacation for a week and in the car ride i wrote a turtle program on notepad++ and want to know if this will work. Pretty much its turtle program to automate a turtle using tekkit and redpower stuff. The point is there will be a 3x3 box with a floor of transposers which suck up what ever lands on them. right above that theres turtles. and on the outside of the box has a main console which im going to use to automate stuff even more later. But the bot will go up to a certain height then go how ever many blocks you set it to go forward then it will go down till it detects a block. then it will dig down and compare the block in front of it to the items in the first six slots. turn left check, and contiunuely turn until it has made a full circle. pretty much it is used to check for all ores around it and harvest them. once it hits bedrock it will take another 20 seconds or so then come back up and return to its start point and drop all but 1 of every item then go back up head back to where it was but go forward one more block then dig, come back, drop off, then go back and go 2 blocks farther then the original position. (Or thats the plan at least.)

So can someone take the following code and paste it in a wireless mining turtle startup file and see if it works??

The code is:


rednet.open("right")
print("Awaiting Connection to Server...")
x,y,z=rednet.receive()
if y=="Go" then
write "Set Distance to Travel"
input = read()
pos = 0
while pos < 3 do
m = tonumber(input)
h = 20
sleep(5)
for i=1, h do
turtle.up()
end
while m > 0 do
turtle.forward()
m = m-1
end
for i=1, 60 do
turtle.down()
end
for i=1, 100 do
turtle.digDown()
turtle.down()
  for i=1, 4 do
	if turtle.compare() == false then
		turtle.turnLeft()
	for i=1, 6 do
turtle.select(i)
	if turtle.compare() == true then
		turtle.dig()
	end
	end
	end
  end
end
turtle.turnLeft()
for i=1, 120 do
turtle.up()
end
while m < 10 do
turtle.back()
m = m+1
end
for i=1, 120 do
turtle.down()
end

OI = "turtle.getItemCount(1)"
# gets amount of iron ore
OC = "turtle.getItemCount(2)"
  # gets amount of copper ore
OG = "turtle.getItemCount(3)"
  # gets amount of gold ore
D = "turtle.getItemCount(7)"
  # gets amount of diamond
L = "turtle.getItemCount(8)"
  # gets amount of Lapis
R = "turtle.getItemCount(9)"
  # gets amount of redstone

c1 = OI-1
c2 = OC-1
c3 = OG-1
c7 = D-1
c8 = L-1
c9 = R-1
#drops all but one of each object
turtle.select(1)
turtle.drop(c1)
turtle.select(2)
turtle.dropc(c2)
turtle.select(3)
turtle.drop(c3)
turtle.select(7)
turtle.drop(c7)
turtle.select(8)
turtle.drop(c8)
turtle.select(9)
turtle.drop(c9)
end
h = h+1
pos = pos+1
end


Once you put that in the wireless mining turtle put down a console with a modem on the side and type "lua" into it. Then open the modem and do rednet.broadcast("Go") and the turtle will ask you how far you want to go. input a small distance just for testing then watch as the magic happens. Please give me feedback i wont be able to test it myself for a few weeks also i dought any one will but if you could take video of it so i could see it would be much appreaciated.

thanks



EDIT: Sorry about not being very organized im not very good with indenting or organizing.
BigSHinyToys #2
Posted 16 August 2012 - 08:06 PM
so it flies up goes ford the distance i specify then digs to bedrock while spinning around and changing inventory slot then sits there spinning for a while before flying back up way past the hight it was before and goes down in a different location (A lake next to the test site) and the throws a error I have edited the code to include the error at the right line. also i made a few small adjustments
Spoiler

local function runScript()
    write "Set Distance to Travel"
    input = read()
    pos = 0
    while pos < 3 do
	    m = tonumber(input)
	    h = 20
	    sleep(5)
	    for i=1, h do
		    turtle.up()
	    end
	    while m > 0 do
		    turtle.forward()
		    m = m-1
	    end
	    for i=1, 60 do
		    turtle.down()
	    end
	    for i=1, 100 do
		    turtle.digDown()
		    turtle.down()
		    for i=1, 4 do
			    if turtle.compare() == false then
				    turtle.turnLeft()
				    for i=1, 6 do
					    turtle.select(i)
					    if turtle.compare() == true then
						    turtle.dig()
					    end
				    end
			    end
		    end
	    end
	    turtle.turnLeft()
	    for i=1, 120 do
		    turtle.up()
	    end
	    while m < 10 do
		    turtle.back()
		    m = m+1
	    end
	    for i=1, 120 do
		    turtle.down()
	    end
	    OI = "turtle.getItemCount(1)"
	    -- gets amount of iron ore
	    OC = "turtle.getItemCount(2)"
	    -- gets amount of copper ore
	    OG = "turtle.getItemCount(3)"
	    -- gets amount of gold ore
	    D = "turtle.getItemCount(7)"
	    -- gets amount of diamond
	    L = "turtle.getItemCount(8)"
	    -- gets amount of Lapis
	    R = "turtle.getItemCount(9)"
	    -- gets amount of redstone
	    c1 = OI-1
	    c2 = OC-1
	    c3 = OG-1
	    c7 = D-1 -- error test80.lua:62:attempt to perform arithmetic __sub on string and number
	    c8 = L-1
	    c9 = R-1
	    --drops all but one of each object
	    turtle.select(1)
	    turtle.drop(c1)
	    turtle.select(2)
	    turtle.dropc(c2)
	    turtle.select(3)
	    turtle.drop(c3)
	    turtle.select(7)
	    turtle.drop(c7)
	    turtle.select(8)
	    turtle.drop(c8)
	    turtle.select(9)
	    turtle.drop(c9)
    end
    h = h+1
    pos = pos+1
end
rednet.open("right")
term.clear()
term.setCursorPos(1,1)
print("Awaiting Connection to Server...")
while true do -- better this way
    x,y,z=rednet.receive()
    if y=="Go" then
	    runScript()
    end
end
Wolf9988 #3
Posted 18 August 2012 - 12:11 AM
Thanks now i need to figure that error out :(/>/>