Jump to content




Armor Repair Crafting turtle help.


14 replies to this topic

#1 Alcheya

  • Members
  • 24 posts

Posted 27 January 2014 - 01:33 AM

I was wondering if I could get help solving a few issues I'm having with this script I was attempting to write.

I have my input chest to the left and my output chest to the right. My input chest is broken armor/tools of the same material. My output chest goes back into my AE system. The input chest will only get broken items (AE fuzzy exports with a 99% split damage), but it recieves them in any order, unsorted. I tried using a filing cabinet to mitigate the "unsorted" part, but it will pull out stacks of armor if I use the filing cabinet (I couldn't figure out how to make it only pull 1 of the item at a time).

One issue I'm still having is that I have to babysit it because it will get stuck with a single item (lets say its done repairing swords and there is only 1 left) and keep picking up the same sword, with the next item in line (pickaxe, for example). So until I pull out that single sword, it will keep trying to combine the pickaxe and sword in a loop. Once I pull the sword, it will move on to the pickaxes (or whatever the next item is in the chest).

The other is, as stated above, that I don't know how to tell it to only pick up 1 of the item and not the entire stack. Is there an extended or advanced API available for crafting turtles? It would be optimal if I could have it scan a chest for items that would equal a total damage value to make repairing optimal to get the maximum back on the items (for example finding a helm with less than 15/75 or less damage value to repair a helm with 60/75 or more damage value).

Actually, any extra documentation or commands that might be used in doing this for me would be great in helping me figure this out. I just threw this together from what I found on the wiki, but I'm not even sure I properly understood it. It works for now, with babysitting, but I would like to get it smoother so I could set it and forget it. Thanks in advance.


while true do
   turtle.turnLeft()
   turtle.select(1)
   turtle.suck(1)
   turtle.select(2)
   turtle.suck(1)
      if turtle.getItemCount(1) == 1 and turtle.getItemCount(2) == 1 then
        turtle.craft(1)
        turtle.turnRight()
        turtle.turnRight()
        turtle.select(1)
        turtle.drop()
        turtle.select(2)
        turtle.drop()
        turtle.turnLeft()
     else
        turtle.turnRight()
        turtle.turnRight()
        turtle.select(1)
        turtle.drop()
        turtle.select(2)
        turtle.drop()
        turtle.turnLeft()
    end
end


#2 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 27 January 2014 - 01:46 AM

As for the turtle.suck() issue, you are running up against the limits of that particular command. The current version of turtle.suck() will pick up all items from an inventory slot in a chest. However, according to dan200, the next release addresses this issue. New CC 1.6 feature: turtle.suck( quantity). I am not sure if there are other methods like using routers or AE to limit the number of items in the chest to 1 at a time. I will let someone else address that.

#3 Alcheya

  • Members
  • 24 posts

Posted 27 January 2014 - 02:04 AM

View Postsurferpup, on 27 January 2014 - 01:46 AM, said:

As for the turtle.suck() issue, you are running up against the limits of that particular command. The current version of turtle.suck() will pick up all items from an inventory slot in a chest. However, according to dan200, the next release addresses this issue. New CC 1.6 feature: turtle.suck( quantity). I am not sure if there are other methods like using routers or AE to limit the number of items in the chest to 1 at a time. I will let someone else address that.

Ahh, that might explain why turtle.suck(1) wasn't working the way I thought it would. That's why I'm using chests instead of the filing cabinets. (actually, I just put an ender IO item duct to an "input chest" from the filing cabinet so I didn't have to tear my entire setup down until I figured it all out).

Would be much easier if it was all the same items, but I'm using those spawners from rogue dungeons along with cursed earth. I end up with hundreds of different pieces of armor in no time and I really hate just throwing stuff away.

#4 CometWolf

  • Members
  • 1,283 posts

Posted 27 January 2014 - 02:37 AM

Based on the mods you've mentioned, im guessing you probably have openPeripherals installed. In which case you can use the following code.
tStacks = peripheral.call(directionString,"getAllStacks") --probably not the right method... OpenP docs are stupid.
This will give you a table of all the items in the ches, with name, id, stack size and a few other thingst. There's also push and pull functions for moving specific amounts and specific items. Check out the docs program included in the mod. Just note that the comments in the first lines are done wrong, so the program errors lol

#5 Alcheya

  • Members
  • 24 posts

Posted 27 January 2014 - 02:42 AM

View PostCometWolf, on 27 January 2014 - 02:37 AM, said:

Based on the mods you've mentioned, im guessing you probably have openPeripherals installed. In which case you can use the following code.
tStacks = peripheral.call(directionString,"getAllStacks") --probably not the right method... OpenP docs are stupid.
This will give you a table of all the items in the ches, with name, id, stack size and a few other thingst. There's also push and pull functions for moving specific amounts and specific items. Check out the docs program included in the mod. Just note that the comments in the first lines are done wrong, so the program errors lol

Yes, I do have openPeriphs. I'll take a look at that. Thanks.

#6 Alcheya

  • Members
  • 24 posts

Posted 27 January 2014 - 05:30 AM

Well, I looked into it, but to pull to the turtle itself, I need to make a narcissistic turtle (according to what I read) and there is no documentation on how to make one. :P

#7 CometWolf

  • Members
  • 1,283 posts

Posted 27 January 2014 - 05:36 AM

Narcissistic turtle? Wtf, lol.
If you're pulling from a chest, you should be able to use the chest itself as a peripheral and push items into adjacent inventories.

Edited by CometWolf, 27 January 2014 - 05:36 AM.


#8 Alcheya

  • Members
  • 24 posts

Posted 27 January 2014 - 05:45 AM

View PostCometWolf, on 27 January 2014 - 05:36 AM, said:

Narcissistic turtle? Wtf, lol.
If you're pulling from a chest, you should be able to use the chest itself as a peripheral and push items into adjacent inventories.

I need to pull into the crafty turtle to repair the items, but in order to pull into itself, I would need a "narcissistic crafty turtle."

edit: Ah, i see what you mean, but I want to pull from the south of the turtle and push to the north of the turtle back into the AE network.

edit2: nevermind, I get it now. Using the chest as a periph I can push to the turtle, then just use the regular turtle commands to "drop" to the right place. I'll give it a shot.

Edited by Alcheya, 27 January 2014 - 05:52 AM.


#9 CometWolf

  • Members
  • 1,283 posts

Posted 27 January 2014 - 05:48 AM

Where are you getting this info? I know for a fact you can do what im saying with any computer/turtle

#10 Alcheya

  • Members
  • 24 posts

Posted 27 January 2014 - 05:54 AM

View PostCometWolf, on 27 January 2014 - 05:48 AM, said:

Where are you getting this info? I know for a fact you can do what im saying with any computer/turtle

I got it from mikemoo's post in FTB forums where he told someone they needed a narcissistic turtle to use the turtle's own inventory in the way I was assuming I'd have to use it to get it to work with openperiphs.

#11 CometWolf

  • Members
  • 1,283 posts

Posted 27 January 2014 - 06:04 AM

Ignore the turtle's inv. What you're using is the chest's inventory to push items into adjacent inventories, in this case the turtle.
Here's an advanced example.
http://pastebin.com/JRPN0P8x from Line 696
Im on the phone, otherwise i'd post the exact part im takling about :P

Edited by CometWolf, 27 January 2014 - 06:08 AM.


#12 Alcheya

  • Members
  • 24 posts

Posted 27 January 2014 - 06:10 AM

View PostCometWolf, on 27 January 2014 - 06:04 AM, said:

Ignore the turtle's inv. What you're using is the chest's inventory to push items into adjacent inventories, in this case the turtle.
Here's an advanced example.
http://pastebin.com/JRPN0P8x from Line 696
Im on the phone, otherwise i'd post the exact part im takling about :P

lol, yea.. I figured that part out. basically got exactly what I had before and I can actually use the filing cabinet without pulling out the entire inventory. I think I can do "i +1" when the items don't match to get it to move on to the next item if there is a hiccup in the system. I'll get on that.

#13 Slackratchet

  • Members
  • 10 posts

Posted 04 February 2014 - 07:29 PM

It's funny, I was working on something like this today myself but never realized a Crafty Turtle could repair items like an Anvil.

I have a turtle with an AE Fuzzy export bus pointed at it receiving all the damaged armor my mob grinder produces. It looks for duplicates and until recently was dumping them into an Auto-Anvil. Now it drops them to a Crafty Turtle who fixes them and dumps them back into the AE system since sometimes they're not completely repaired after one pass. Fully repaired suits go to the Smeltry for smelting into ingots.

Thanks for the info. Saves me power and essence. :)

#14 SmilinJoe

  • New Members
  • 1 posts

Posted 27 February 2014 - 02:44 AM

Would you mind posting what you have working so far. I am trying to learn this stuff, and seeing how the initial program has progressed would help out a lot.

Joe.

#15 Xastabus

  • Members
  • 4 posts

Posted 14 October 2014 - 12:00 AM

Hello,
Sorry if I'm resurrecting a dead thread but I'm trying to do this myself and just getting into ComputerCraft, Lua, Turtles, etc...

I wrote the script below to run on multiple turtles, each sitting in front of separate chests that I fill with damaged armor and tools. It seemed to be working great, then I noticed the turtle repairing Chainmail items got clogged. (Issue is not specific to Chainmail items, read on...)

My process is the turtle fills its inventory with items from the chest, compares each item in sequence to items higher in the list until it finds a match, drops all but the first matched pair, crafts, then dumps all slots (because I noticed it sometimes would fail to craft from certain slot pairs). This was working perfectly until I upgraded ComputerCraft to 1.63. I'm running a modified FTB Monster 1.1.1 and have updated several mods, ComputerCraft wouldn't connect to Big Reactors so I had to update it. (After the update it appears turtle.compareTo no longer accepts "fuzzy" matches and will only match like items if their damage values also match. This has slightly broken my process.)

So, I guess what I need to know is, did compareTo change and is there any way to get "fuzzy" compare back?

Thanks,
Xast.
--[[ Tool & Armor Repair ]]--
--[[ Written by Xastabus ]]--
--[[ Last update: 10/13/2014 ]]--
function getStuff()
  for i=1,16 do
	turtle.suck(1)
  end
end
function checkStuff()
  for x=1,15 do
	turtle.select(x)
	for i=x+1,16 do
	  c=turtle.compareTo(i)
	  if c==true then
		return x,i
	  end
	end
  end
end
function dropStuff(a,B)/>/>/>/>
  for i=1,16 do
	if ((i~=a)and(i~=B)/>/>/>/>) then
	  turtle.select(i)
	  turtle.drop()
	end
  end
end
function dropAll()
  for i=1,16 do
	turtle.select(i)
	turtle.drop()
  end
end
dropAll()
while true do
  turtle.select(1)
  getStuff()
  a,b = checkStuff()
  dropStuff(a,B)/>/>/>/>
  turtle.craft()
  dropAll()
  sleep(5)
end

Edit: It would appear that "turtle.getItemDetail()" was added in ComputerCraft 1.64 which would allow one to test for matching item names while ignoring the damage. Unfortunately this doesn't help me as 1.64 requires MC 1.7.10 and the world I am playing in is rather stuck in MC 1.6.4. :(

Edited by Xastabus, 14 October 2014 - 01:29 AM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users