Jump to content




Advanced Programs: Orefinder, Tunnel.

turtle

253 replies to this topic

#41 Henness

  • Members
  • 189 posts

Posted 26 November 2012 - 09:50 PM

View Postthesonofdarwin, on 26 November 2012 - 06:25 AM, said:

I've been using v1.3.1 to clear some rooms and I've noticed it sometimes changes its vertical mining location. I thought it was caused when it encountered an air space above or in front, but after some testing that didn't seem to be the case. Here's an image of a room created by this turtle. The last two rows he decided to shift two deeper. Neither myself or enemies spawned in its way and it had plenty of inventory space. Torch was placed after the fact, so it wasn't that either. Edit: Nevermind. Set up 6 turtles at the same time and it was just the one doing it. Not sure why though since I added this program directly to the mod .zip, so they were all using the same information... Just shipped that turtle to the lava and all seems fine now.

That usually what happens when it hit bedrock but from your picture doesn't look like it could have. The turtle doesn't know if there is water or lava so I don't think that caused it. Idk I'll keep my eye out but I haven't seen any thing like that yet and your the first to see it. I wont write it off as bug. Might have just been the lua lagging? I have know Idea.

View PostChunLing, on 26 November 2012 - 02:38 PM, said:

...you what? Tell me that you mean you set that turtle to lava mining. Even if that's not what you mean, please tell me it is.

Apparently he tossed and burned the turtle in lava???...

#42 Henness

  • Members
  • 189 posts

Posted 02 December 2012 - 01:48 AM

Just posted my new program OreFinder. Should be fairly bug free I used it for a few days now with no problems. Hope you guys like it, I'll post some pictures soon.

#43 Peewee

  • New Members
  • 5 posts

Posted 04 December 2012 - 06:10 AM

Works pretty well! The way you figure out whether or not to dig at a certain spot is a little strange; you can just do math.mod(2*z+x, 5) and get the same pattern without the if/then blocks. That has the added benefit of allowing multiple digging sessions to overlap if they all use the same coordinate system.

Speaking of multiple digging sessions, any plans on making it use persistant variables so it can survive server resets or being unloaded?

#44 Henness

  • Members
  • 189 posts

Posted 04 December 2012 - 11:57 AM

View PostPeewee, on 04 December 2012 - 06:10 AM, said:

Works pretty well! The way you figure out whether or not to dig at a certain spot is a little strange; you can just do math.mod(2*z+x, 5) and get the same pattern without the if/then blocks. That has the added benefit of allowing multiple digging sessions to overlap if they all use the same coordinate system.

Speaking of multiple digging sessions, any plans on making it use persistant variables so it can survive server resets or being unloaded?

I'll have to have a look at that, yes I want to add persistant variables I just have no idea how.

#45 ChunLing

  • Members
  • 2,027 posts

Posted 04 December 2012 - 03:59 PM

save them in a table, textutils.serialize() the table and save that in a file, opposite process on a restart.

#46 Henness

  • Members
  • 189 posts

Posted 04 December 2012 - 08:50 PM

View PostPeewee, on 04 December 2012 - 06:10 AM, said:

Works pretty well! The way you figure out whether or not to dig at a certain spot is a little strange; you can just do math.mod(2*z+x, 5) and get the same pattern without the if/then blocks. That has the added benefit of allowing multiple digging sessions to overlap if they all use the same coordinate system.

Speaking of multiple digging sessions, any plans on making it use persistant variables so it can survive server resets or being unloaded?

Wouldn't it have to be math.mod((x+4)-2(z-1), 5)???

#47 Peewee

  • New Members
  • 5 posts

Posted 04 December 2012 - 09:44 PM

Perhaps. I was just letting you know there was an easier way to produce a mineshaft pattern which reveals every block, so I didn't bother adding constants to make it line up perfectly.

#48 DarkriftX

  • New Members
  • 15 posts

Posted 06 December 2012 - 06:06 AM

I do not know what I am missing, but I get an error on line 129 "attempt to assign nil". I have tried with and without items to ignore and cannot get it to mine more than a block with orefinder. If this is not a current bug, can you provide some more details as to how its supposed to be used incase I am doing it wrong?

#49 Henness

  • Members
  • 189 posts

Posted 07 December 2012 - 09:13 AM

View PostDarkriftX, on 06 December 2012 - 06:06 AM, said:

I do not know what I am missing, but I get an error on line 129 "attempt to assign nil". I have tried with and without items to ignore and cannot get it to mine more than a block with orefinder. If this is not a current bug, can you provide some more details as to how its supposed to be used incase I am doing it wrong?

Can you tell me what parameters you are typing in? Also When I run it I put dirt in slot 1, gravel in slot 2, and stone in slot 3. Then sense I don't want it to mine 3 different materials you enter "3" for the last question.

#50 DarkriftX

  • New Members
  • 15 posts

Posted 07 December 2012 - 10:00 AM

I probably tried all params. I tried all even numbers, all odds, longer ones, shorter. I even tried for example putting 3 blocks (dirt gravel cobble) and leaving skip blank (0), entering 3, entering 2, entering 4, you name it. I have tried all possible combos. I even re-downloaded the script and used notepad++ to make sure the code looked properly formatted (notepad itself messes up the ln/br's).

#51 Henness

  • Members
  • 189 posts

Posted 07 December 2012 - 11:47 AM

View PostDarkriftX, on 07 December 2012 - 10:00 AM, said:

I probably tried all params. I tried all even numbers, all odds, longer ones, shorter. I even tried for example putting 3 blocks (dirt gravel cobble) and leaving skip blank (0), entering 3, entering 2, entering 4, you name it. I have tried all possible combos. I even re-downloaded the script and used notepad++ to make sure the code looked properly formatted (notepad itself messes up the ln/br's).

I started looking at the code and it turns out that on line 129 there was a typo, I don't know why it was working for some people and not you but I fixed it and uploaded a new version. Thanks for letting me know that you were having problems.

#52 DarkriftX

  • New Members
  • 15 posts

Posted 08 December 2012 - 04:16 AM

I fixed your typo in my version because I had already attempted some edits. I want the turtle to return back when its done and drop its load instead of just sitting at the end for me to have to chase down. I almost have it but it returns a row off (I do 1 for the width with multiple bots running in parallel). I havent finished it (need to tell it to not go back to returnX once its done) but I need to figure out why it is is off a row. Figured that instead of bashing my head against a wall on a language I do not know yet, maybe you might be interested in adding this feature. Also, I was thinking it might be handy to have the bot cover the copy of its hole in with a single cobble when it gets back to the top to make the area semi safe.

What my turtle does is ([X] = chest):


<drop stuff-------------------------------------------------
[X]>dig----dig----dig----dig----dig----dig----dig----dig--^


***EDIT*** I fixed the above problem.

Now I am trying to figure out how you are telling it how many blocks to skip before it digs down. For example I would like it to dig down, then move on 2 blocks dig down, etc. Currently it moves 5 blocks between digs. Could you help point me in the correct location (or add this as an option in the beginning)?

-- Advanced Ore Finder by Henness
-- Version 1.0 11/21/2012

-- Config
Version = "v1.0"
local Width
local Length
local Depth
local Ignore

function version() -- Version function
return Version
end

function regwrite(string, columnVar, rowVar) -- Write a string to the cords
term.setCursorPos( columnVar, rowVar )
write (string)
end

function clearscreen() -- Clearscreen function
term.clear()
regwrite( "AP Ore Finder", 15, 1 )
regwrite( version(), 2, 13 )
regwrite( "Designed by Henness", 20, 13 )
term.setCursorPos( 1, 3 )
end

function refuel(stop) -- Refuels the turtle
returnXF = (Width - x) * 2
if math.fmod( VarX , 2 ) == 0 then
returnYF = (Length - (Length - y) - 1) * 2
else
returnYF = (Length - y) * 2
end
if turtle.getFuelLevel() < ((Depth * 2) + returnXF + returnYF + 5) and turtle.getItemCount(16) > 1 then
turtle.select(16)
turtle.refuel(turtle.getItemCount(16) - 1)
end
if stop == true then
turtle.select(16)
repeat
turtle.refuel(turtle.getItemCount(16) - 1)
sleep(0.1)
until turtle.getFuelLevel() > ((Depth * 2) + returnXF + returnYF + 5)
end
if turtle.getFuelLevel() < ((Depth * 2) + returnXF + returnYF + 5) and stop ~= true then
returnToStart(true)
end
end

function empty() -- Emptys the turtles inventory
if turtle.getItemCount(15) > 0 then
returnToStart()
end
end

function returnToStart(stop) -- Returns to start
returnX = Width - x
if math.fmod( VarX , 2 ) == 0 then
returnY = Length - (Length - y) - 1
turnRight()
else
returnY = Length - y
turnLeft()
end
moveForward(returnX)
turnLeft()
moveForward(returnY)
if stop == true then
clearscreen()
print("Too low on fuel to continue. Please insert more fuel.")
refuel(true)
end
for i=Ignore+1,15,1 do
turtle.select(i)
turtle.drop()
end
turnLeft(2)
moveForward(returnY)
turnRight()
moveForward(returnX)
if math.fmod( VarX , 2 ) == 0 then
turnRight()
else
turnLeft()
end
end



function moveUp(distance) -- Moves Up
if distance == nil then
distance = 1
end
for i=1,distance,1 do
repeat
if turtle.up() == true then
moved = true
else
digUp()
turtle.attackUp()
moved = false
end
until moved == true
end
end

function moveForward(distance) -- Moves Forward
if distance == nil then
distance = 1
end
for i=1,distance,1 do
repeat
if turtle.forward() == true then
moved = true
else
digForward()
turtle.attack()
moved = false
end
until moved == true
end
end

function moveDown(distance) -- Moves Down
if distance == nil then
distance = 1
end
for i=1,distance,1 do
repeat
if turtle.down() == true then
moved = true
else
digDown()
turtle.attackDown()
moved = false
end
until moved == true
end
end

function turnLeft(a) -- Turns Left
if not a then a = 1 end
for i=1,math.abs(a),1 do
turtle.turnLeft()
end
return true
end

function turnRight(a) -- Turns Right
if not a then a = 1 end
for i=1,math.abs(a),1 do
turtle.turnRight()
end
return true
end

function digForward(Compare) -- Digs Forward
if turtle.detect() then
if Compare then
SlotVar = Ignore
Ore = true
for i=1,SlotVar,1 do
turtle.select(i)
if turtle.compare() == true then
Ore = false
end 
end
if Ore == true then
turtle.dig()
end
else
turtle.dig()
end
end
end

function digDown(Compare) -- Digs Down
if turtle.detectDown() then
if Compare then
SlotVar = Ignore
Ore = true
for i=1,SlotVar,1 do
turtle.select(i)
if turtle.compareDown() == true then
Ore = false
end 
end
if Ore == true then
turtle.digDown()
end
else
turtle.digDown()
end
end
end

function digUp(Compare) -- Digs Down
if turtle.detectUp() then
if Compare then
SlotVar = Ignore
Ore = true
for i=1,SlotVar,1 do
turtle.select(i)
if turtle.compareUp() == true then
Ore = false
end 
end
if Ore == true then
turtle.digUp()
end
else
turtle.digUp()
end
end
end

function compareSides(n) -- Compares surounding blocks with items in the inventory
for i=1,n,1 do
digForward(true)
turnRight()
end
end

function findDown(z) -- Finds all ores bellow the turtle
refuel()
empty()
for i=1,z,1 do
digDown(true)
if turtle.detectDown() then
digDown(false)
end
moveDown()
compareSides(4)
end
for i=1,z,1 do
moveUp()
end
end

function runFinder( W , L , D )
VarY = 5
VarX = 1

x = W
y = L
while x > 0 do
y = L
while VarY <= 5 and y > 1 do
if VarY == 5 then
findDown(D)
VarY = 0
end
digForward(true)
if turtle.detect() then
digForward(false)
end
moveForward()
VarY = VarY + 1
y = y - 1
end
if VarY == 5 then
findDown(D)
VarY = 0
end
if x > 1 then
if math.fmod( VarX , 2 ) == 0 then
turnLeft()
digForward(true)
if turtle.detect() then
digForward(false)
end
moveForward()
turnLeft()
if VarY == 0 then
VarY = 3
elseif VarY == 1 then
VarY = 2
elseif VarY == 2 then
VarY = 1
elseif VarY == 3 then
VarY = 5
elseif VarY == 4 then
VarY = 4
end
else
turnRight()
digForward(true)
if turtle.detect() then
digForward(false)
end
moveForward()
turnRight()
if VarY == 0 then
VarY = 2
elseif VarY == 1 then
VarY = 1
elseif VarY == 2 then
VarY = 5
elseif VarY == 3 then
VarY = 4
elseif VarY == 4 then
VarY = 3
end
end
VarX = VarX + 1
end
x = x - 1
end
end
function emptyinv()
for i=Ignore+1,15,1 do
turtle.select(i)
turtle.drop()
end
end

function finished() -- Returns to start
if Width == 1 then
returnX = 0
else
returnX = Width - x
end
if math.fmod( VarX , 2 ) == 0 then
returnY = Length - (Length - y) - 1
turnRight()
else
returnY = Length - y
turnLeft()
end
moveForward(returnX)
turnLeft()
moveForward(returnY)
print("Clearing Inventory.")
for i=1,16,1 do
turtle.select(i)
turtle.drop()
end
end

-- RUN
clearscreen()
print("Width of Area?")
Width = tonumber(read())

clearscreen()
print("Length of Area?")
Length = tonumber(read())

clearscreen()
print("Depth of Holes?")
Depth = tonumber(read())

clearscreen()
print("How many materials will be Ignored?")
Ignore = tonumber(read())

clearscreen()
print("Finding Ore...")
runFinder( Width , Length , Depth )
print("All done, returning home.")
finished()
turnLeft()
turnLeft()
print("Run complete.")


#53 DarkriftX

  • New Members
  • 15 posts

Posted 08 December 2012 - 05:04 AM

Also, one more thing I noticed is that when it is at its home level and it is digging towards the next hole it ignores ores right above it. Would it cost all that much more time to have it digForward() then digUp() then moveForward()? I heard someone say that every check or action adds quite a bit of time to the process but I dont know the language nor the implementation very well.

#54 ChunLing

  • Members
  • 2,027 posts

Posted 08 December 2012 - 05:37 AM

It doesn't add a huge amount of time but it is noticeable.

#55 vafo

  • Members
  • 10 posts

Posted 08 December 2012 - 10:29 AM

The advanced ores program is awesome, if not with some quirks. I had it stopping by hitting gravel when coming back to the first row...not sure why.

What I wanted to ask is, would it be too hard to have it come back and unload when it ends the execution? kinda hard to go grab it at the opposite end of the start.

#56 DarkriftX

  • New Members
  • 15 posts

Posted 08 December 2012 - 09:32 PM

If you look above, the code I posted does that. I just added a few lines of code to the original.

#57 Henness

  • Members
  • 189 posts

Posted 08 December 2012 - 10:47 PM

View PostDarkriftX, on 08 December 2012 - 05:04 AM, said:

Also, one more thing I noticed is that when it is at its home level and it is digging towards the next hole it ignores ores right above it. Would it cost all that much more time to have it digForward() then digUp() then moveForward()? I heard someone say that every check or action adds quite a bit of time to the process but I dont know the language nor the implementation very well.

View Postvafo, on 08 December 2012 - 10:29 AM, said:

The advanced ores program is awesome, if not with some quirks. I had it stopping by hitting gravel when coming back to the first row...not sure why.

What I wanted to ask is, would it be too hard to have it come back and unload when it ends the execution? kinda hard to go grab it at the opposite end of the start.

I have been completely rewriting the orefinder program because when I wrote it I kinda just through it together, I'm basing the new version off of gps cords so its easier to get the turtle to go places. I'm also adding a really nice gui and making it so you can pause the program at any time and even continue your program after server restarts. So with the new one I'll make the turtle return. I could also make it mine ores on the ceiling.

#58 bigsushi

  • New Members
  • 1 posts

Posted 09 December 2012 - 04:28 AM

I must be doing something wrong. Every time I try and start the Advanced Tunneling program it accepts the dimensions of the tunnel and the yes/no for torches but when it starts, it only mines the one block in front of it and then doesn't do anything. The status shows 0% when clicked on. I figure this must be user error but I have no idea what I'm doing wrong.

Thanks for any help.

#59 DarkriftX

  • New Members
  • 15 posts

Posted 09 December 2012 - 06:32 AM

Awesome Henness. I will wait for your version then instead of screwing around with it much more. Do you think that you might also make the gap between holes variable? I thought I figured out how to change it from 5 to 3 but when I did that the turtle started mining in random directions and kicking my ass lol

#60 Henness

  • Members
  • 189 posts

Posted 09 December 2012 - 09:03 AM

View Postbigsushi, on 09 December 2012 - 04:28 AM, said:

I must be doing something wrong. Every time I try and start the Advanced Tunneling program it accepts the dimensions of the tunnel and the yes/no for torches but when it starts, it only mines the one block in front of it and then doesn't do anything. The status shows 0% when clicked on. I figure this must be user error but I have no idea what I'm doing wrong.

Thanks for any help.

Sounds like you need the refuel the turtle before you start the program, that program was made a while ago so it doesn't drop of items and it doesn't refuel while the program runs.

View PostDarkriftX, on 09 December 2012 - 06:32 AM, said:

Awesome Henness. I will wait for your version then instead of screwing around with it much more. Do you think that you might also make the gap between holes variable? I thought I figured out how to change it from 5 to 3 but when I did that the turtle started mining in random directions and kicking my ass lol

I don't think I'm gonna add that, the reason it digs in that pattern is because the pattern allows the turtle to check all of the blocks in the area with very minimal digging. There shouldn't be any point to making it dig every 3 blocks, it would just end up checking some blocks more than once. Is there a reason you want it to do that?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users