Jump to content




[Question]How to edit the existing Excavate script?


  • You cannot reply to this topic
6 replies to this topic

#1 xInDiGo

  • Members
  • 105 posts

Posted 13 January 2013 - 10:27 AM

i'd like to try and edit the existing excavate script. my goal here is to add a filter to it. could anybody help get me started or point me in the right direction?

i'm trying to get a turtle to destroy everything like in excavate except for the first few blocks in its inventory. i know it should look something like this
while not move forward
  if turtle.compareforward() = false
    then
	  turtle.select(2)
    else
	  turtle.dig()
else
turtle.forward()
end

i know this script is awful and full of bugs but its how i'd think it may look. something similar perhaps. i know it doesn't compare the other slots yet, but maybe w/ some help i can get this working.

thanks for your time!

#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 13 January 2013 - 10:36 AM

You won't be able to edit it because it's inside the rom folder which is un-writable.

Copy it to your turtle as excavate and then edit it from there.

cp rom/programs/turtle/excavate excavate


#3 xInDiGo

  • Members
  • 105 posts

Posted 13 January 2013 - 11:03 AM

ah okay, that'll make it easier for me! but now for the filtering. any idea how that may look? what confuses me is getting it to check multiple slots :(

#4 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 13 January 2013 - 11:07 AM

Use a simple for loop:

inventoryToStartAt = 3
inventoryToEndAt = 9

for i = inventoryToStartAt, inventoryToEndAt do
    -- What do you mean by destroy the inventories? Do you mean drop the blocks?
    turtle.select(i)
    turtle.drop()
end


#5 xInDiGo

  • Members
  • 105 posts

Posted 13 January 2013 - 11:12 AM

no it doesn't have to drop anything. just NOT break specific blocks in its inventory, or return them either i guess when it goes back to refuel/deposit. i'm looking at the excavate script now & its pretty confusing :(
i figure i just need to add a function near the place where it tries to dig. but i just realized that the default excavate stops when it can't dig anymore, so i'm wondering if putting a filter on it will cause it to stop prematurely >.<

#6 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 13 January 2013 - 11:18 AM

Oh, ok then you need the block you don't want the turtle to break in the turtle in any slot and then you turtle.compare() / compareUp() compareDown()

turtle.select(16) -- lets say you put the block you don't want to break in slot 16 (if you're not using tekkit....)
if turtle.compare() or turtle.compareUp() or turtle.compareDown() then
    -- code if it is that block
else
   -- code if it isn't
end

Something like that?

#7 xInDiGo

  • Members
  • 105 posts

Posted 13 January 2013 - 11:28 AM

yes exactly, so in the else section would i have it switch to slot 2 and have another if statement in there? and then lets say in that If statement in that Else i'd have it break? so like:

turtle.select(1) -- lets say you put the block you don't want to break in slot 1
if turtle.compare() or turtle.compareUp() or turtle.compareDown() then
    -- move along
else
   turtle.select(2)
	  if turtle.compare() or turtle.compareUp() or turtle.compareDown()
	  then
		 -- move along
	  else
		 turtle.select(3)
		   if turtle.compare() or turtle.compareUp() or turtle.compareDown()
			  then
				  -- move along
			  else
				    turtle.dig()
end

sorry i know thats REALLY bad but i'm trying to learn as i go!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users