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

Items Sorting Turtle [Selfbuilding][Quarry-suitable][Rednet][0.4.1+]

Started by unobtanium, 18 January 2013 - 10:31 AM
unobtanium #1
Posted 18 January 2013 - 11:31 AM


Hello MinecraftCommunity,

it's me again, and this time i presenting you my Items Sorting Turtle.
This Turtle will set up a layout and then takes out item stacks from a chest to put these in a chest for each individual kind of item. This could be used for items from a quarry. Now with rednet!!!
Feel free to leave feedback on this to keep me updating.
PS: 3000 views and 300 downloads! Great :D/>

ITEMS SORTING TURTLE BETA 0.4.1
SpoilerThis version sorts one type of item in every chest.

Build & Sort Programs (no rednet):
http://pastebin.com/hcwy8SQ2

Rednet:
Sort Programs for the computer:
http://pastebin.com/TrjyFSrm

Sort Programs for the turtle:
http://pastebin.com/MRanV9Gg

ITEMS SORTING TURTLE BETA 0.4.1+
SpoilerThis version sorts up to four items in a single chest. You have to place the items you want to have sorted in the chest, in the first top left four slots of the chest. You can have just one, two, three or four items in the chest as indicators. In empty chests it still will drop just one item instead of four.

Build & Sort Programs (no rednet):
http://pastebin.com/6kENkkFL

Rednet:
Sort Programs for the turtle:
http://pastebin.com/tkTgfCkJ

Sort Programs for the computer: "isc" is still the same! Use the program above!

Installation:
Install the program with the following code typed in your turtle:

pastebin get hcwy8SQ2 ist


Programs:
Type

ist
in your turtle to start the program and get into the menu.

Build standard layout
This program needs a mining turtle. I will change this in the future, so a normal turtle will be enough.
Place the Turtle on the ground. It needs one block space in the front and two to the left. The back will be the user interaction and where the chests will be displayed. Its accually the front :D/>
The chests where the items will be stored after sorting them, will be build to the right. Examples down below.
If you start the program, it asks you how many horizontal chests you want. This means how many lines of chests will be set up. The bigger this number is, more space is needed to the right.
The second question is how many vertical chests you want to have for the storage. The bigger this number is, the higher will be the whole storage.
After typing in the two numbers, it will show you how many items you need:
In this case i wanted three horizontal chests but just one height.
I put the needed materials allready in the slots of the turtle.
This will build the sorting layout you can see at the top of this post.



The pattern of the materials needed for this program is like the following picture:


Spoilercoal
chest
chest
chest
block
block
block
block
block
block
block
block
stair
stair
stair
stair

After pressing Enter the Turtle should start building it. Stay back and be sure nothing blocks the turtle.
If the Turtle finished its job, it stays in the base. From there you can start the sort program.

Build compact layout
Does the same like the standard layout building program above.
You dont have to use chests to run the program. You can place them manually later on if you want to.If you use chests, the Turtle needs chests which dont connect to each other. If you place the chests manually, you can make a crossed pattern with normal chests and another kind of chest. (If trapchests are avaiable i recommand these!)
You have to use the sorting program for compact layouts!




Start standard sorting
This is the main program of the pack.
Place the items you want to sort into the bottom left chest (lowerst one of the four ones! You can put an enderchest there, too).
Above this chests, put some coal or charcoal. At least ten.
The last two chests should be empty. The Turtle will drop all items which couldn't be sorted in these top chests.
The Turtle needs two coal or charcoal in the last slot (bottom right).
After starting the program the Turtle will take out the materials from the lowest chest and sort them into the other ones to the right. If one of the chests are empty, it automatically fills it with an item which wasnt sorted allready. However, you can put one item you want to have sorted in the chest in it.
If one chest is full, the turtle continues sorting and maybe put it into an empty chests further right. If the turtle reaches the last chest and there are still items left in the inventory, these items will be dropped in the top two chests near the base.
If this was too confusing, just try it out! It makes sense :D/>

Start compact sorting
This program does the same like for standard sorting. It just travels one block instead of two to get to the next chest.

Example:
Check out the picture at the top of this post. I wanted 3 horizontal and one vertikal chest.
More expamples:

Spoiler15
1
Spoiler3
4

Spoiler2
2



Updates:
SpoilerBeta Version 0.4.1+
- fixed sorting program; if a chest was full the last slot was still full and messed up the following chest.
- fixed refueling at the start of the programs
- added new version for more items in a single chest

Beta Version 0.4.1
- fixed turtle rednet program


Beta Version 0.4
- changed build and sort program. Now doesnt use vertical chests for the same item.

Beta Version 0.3
- added compact versions
- added rednet usage

SpoilerBuild Programs and without Rednet:
P3BmaM3X

Rednet:
Sort Programs with Rednet for the Turtle:
TQftvpRA

Sort Programs with Rednet for the Computer:
44mKDtMw

Beta Version 0.2
- added menu
- improved refueling
- improved the display of the needed blocks (isnt shown on the pictures above yet)

To-Do:
- a normal turtle can build the layout

More programs made by myself:
Items Sorting Turtle — Set up a sorting layout with chests and let it sort items for you. Perfect for Quarries!
ULTIMATE WOOD CHOPPER — Set up a farm to chop wood or cut down single 1x1 or 2x2 trees.
Turtle Interactions - Simply naviagate the turtle with a menu
Two High Door - Opens one or more two high doors over rednet.


That's it! I hope i didn't forget anything. Btw, my english isnt the best :/
Because the program is still in beta i cant say that it is bugfree!
If there are any questions, suggestions, errors or bugs, feel free to leave a comment to improve this program pack.
Thank you for your attention.
UNOBTANIUM
xInDiGo #2
Posted 22 January 2013 - 08:59 PM
this is fantastic! i replaced the drop off chest with an enderchest and have my other turtles deposit into an enderchest! gonna see if i can make a simple script to loop istsort ;)/>

thanks for this!
unobtanium #3
Posted 22 January 2013 - 10:50 PM
hey, nice to see you again :D/>
Can you show me the loop script if you have it done? Maybe i will implement this if its usefull for more people :D/>
Or do you just want to let the turtle wait for more items in the enderchest`?

NEW VERSION OUT!
xInDiGo #4
Posted 23 January 2013 - 05:59 AM
basically yeah i'm trying to just get it to check every once in a while for items in the enderchest. the script would be something simple to just run the istsort program over and over every 3 minutes or so. i like the way it is now cause i'm able to use rednet to tell it to sort, & if you made it all one program that may be more difficult for me to do!

one question, when it asks how many chests per item, lets say i make that 2, and it stacks the chests. well if i put a different item i the top chest would that work as another sorting chest? or would it have to be the same as the chest below it?

minor suggestions: if you can make this double sided! (chests on both sides) the way its goes right now, the turtle could easily just turn around after droping an item to deposit other items to a chest behind it. i only mention this cause its really long if you've got lets say 10 chests to sort!


::edit:: the new version doesn't seem to work. i do the build, and then run sort, and i get:
ist:476 attempt to call nill
unobtanium #5
Posted 23 January 2013 - 07:03 AM
I can add the single programs again if you use rednet. The deal is that i didnt get into it yet (i dont even know what it accually does :s). I may take some time to do this. :D/>
I will add the 3 minutes waiting time in the next version.

The turtle checks the slot 16 which item should be placed in the chests. And if a chest is full, there is still the same item in slot 16 from the chest below. It will allways ignore the items you put in the chests above the lowest one. You accually just waste a slot for the storage :D/>

The mirror idea, to have chests on both sides, seems quite nice. The problem is (and thats why i just have chests on on side) that the player has to place the whole building in a free area to have access on both sides. The setup now can be placed on a wall. I will check if i can add this.

I am working on a compact version at the moment. In this one, you use chests, which are not connecting to each other. You also could use a crossed pattern e.g. normal chests and another kind of chest (maybe trapchests some day). This makes a flush wall of chests and would let the Turtle just travel one block to get to the next chest and would be quicker.
xInDiGo #6
Posted 23 January 2013 - 07:14 AM
yeah i just got into rednet last night! i read this tutorial here to learn about rednet! & you're right about needing a free area, but it can be done!

but what about the error i was getting,
ist:476 attempt to call nill
unobtanium #7
Posted 23 January 2013 - 08:43 AM
Thank you for the tutorial link. This looks very awesome and will be added very soon i hope ^^

I cant produce the error myself. Do you know what the Turtle did or at which position it stopped?
xInDiGo #8
Posted 23 January 2013 - 12:09 PM
it was on another computer in a single player game. i'll have to check on it and see what the issue was. i'm trying to do some minor tweaks of my own, to make it more rednet friendly. i'm hoping i can change the shutdown to run my listen command

::edit:: i was able to remove the shutdown and add my listen now i'm working on a repeat, but i noticed its not putting coal in the coal chest. sup w/ that?
unobtanium #9
Posted 25 January 2013 - 01:13 AM
I found the bug and fixed it. I also added a timer which checks for new stuff in the chest every 3 minutes. I also added two new programs if you use rednet. However i didnt implemented that the turtle checks if it has coal in its inventory. I will add it as soon as possible.

NEW VERSION OUT 0.3
xInDiGo #10
Posted 25 January 2013 - 05:44 AM
this is great, i'm very excited to use this! question:

on the compact build does it stack the chests for smaller space or does it just remove the 1 space block?

i think stacking it could make it more compact, you could have 12 chests & it only takes up 3 spaces! sure it may be taller but as far as i can tell most people stack their chests about 3 or 4 tall anyways! if they need more space they can always just upgrade their chest to a gold or diamond chest!
unobtanium #11
Posted 25 January 2013 - 06:01 AM
Thank you!

It still works like before. The Turtle just has to move one less block (accually two because it has to travel back too). It just safes a bit of time.

The longer i think about this, the better it seems to be. It would be an ultimative small storage :D/>
I think i will change/implement this.
xInDiGo #12
Posted 25 January 2013 - 06:45 AM
makes sense in my mind! it seems more intuitive that way! for instance:

you need to make a diamond pick, but your diamonds are all the way in chest 16 down the line! so now you run down 16+ blocks to get your 3 diamonds. But now you need wood, which is in chest 3, so you have to run back! but now, *gasp* the crafting bench is down by chest 10! time to head over there!

anyways, i'm sure you get my point! i hope you enjoyed my short story, and i look forward to seeing what you come up with!
unobtanium #13
Posted 25 January 2013 - 07:28 AM
I think you throw the storage system and this sorting program together ;D
This program is just for sort different items. If you want an item you have to grab it yourself ;D
If i make a logistic storage i will make another program ;D
xInDiGo #14
Posted 25 January 2013 - 08:18 AM
heh i simply meant a more compact sorting system would be easier to use then your current long one. i know that your storage system will be different :P/>
unobtanium #15
Posted 25 January 2013 - 11:37 AM
Allright ^^'
I put the 0.3 Version in the Updates Section if someone still wants to use this one.
In 0.4 the turtle goes layer by layer up and puts in every chest one item. If you make a 3 by 3 pattern you now can store nine different items instead of just three :D/>

NEW VERSION OUT 0.4!!!
xInDiGo #16
Posted 26 January 2013 - 08:35 AM
hey i'm having a problem. after the turtle sorts it just stays are the end of the line and drops the overflow, instead of going back. also, when i quit out of the menu i get an error.

::edit:: removed and reinstalling the program seemed to help, although theres still the error if you quit the program "ist79: Attempt to index ? (a nill value)"

::edit 2:: seems that if i quit the program from the menu, it will glitch if i try to restart it and stay at the end of the chests, and drop the overflow on the ground.
unobtanium #17
Posted 26 January 2013 - 12:11 PM
I have to check and test my programs better before release them -.-
Thank you once again!!!!

This bug was quite difficult to fix. It took three ****ing hours before i found my mistake :D/>
I fixed it now. NEW VERSION OUT! 0.4.1
xInDiGo #18
Posted 27 January 2013 - 01:59 PM
looks like there may be a problem with refueling. i'll play around a bit more and see if i can reproduce the glitch.
unobtanium #19
Posted 28 January 2013 - 12:21 AM
Yep. It selected the first slot for refueling instead of slot 16… this messed it up :D/>
PhilHibbs #20
Posted 29 January 2013 - 11:32 PM
So this only stores one type of item per chest, right? How much slower would it be if it were to check all the items in a chest, so I could have a chest for diamonds, rubies, sapphires, and emeralds; another for all kinds of ores; another for all ingots…
unobtanium #21
Posted 30 January 2013 - 12:15 AM
This would be a very difficult logistic problem, because how the turtle works.
At the moment the turtle sucks one stack out of the chest and checks every stack in the inventory if it is the same kind of item. If yes it drops it back into the chest. The turtle will allways put the stacks in the top left free slot of the chest. I have an idea how to make it but it would take a bit longer, because at the moment i can sort 15 items in one run trough. I need "the amount of items i want to sort in every chest" as free slots in the turtle. If i want to have 8 different items in one chest i have to need 8 free slots in the turtles inventory. And there would be just 8 more free for the items i have to sort. The turtle have to get items more often.
I will see if i can make such a version with four different items :D/>
PhilHibbs #22
Posted 30 January 2013 - 02:02 AM
I don't get it. I haven't studied your script, but wouldn't it just be a case of:

1. Pick up as many stacks from the input chest as will fit in the inventory
2. Go to the first chest
3. Loop through the turtle's inventory comparing each item against the first few stacks in the chest, say 4 or 8
4. If an item in the turtle matches an item in the chest, then dump that stack into the chest
5. Go to the next chest and repeat 3 and 4
6. Dump remaining inventory in the last chest

That would allow each chest to contain as many different item types as you want to check for in Step 3. You just need to make sure that there is one of each item type in the first few slots. Performance tuning would be required to pick a reasonable upper limit. Sorting the chest would break this though as you'd end up with the same item type, maybe it could loop through the items until it's found 4 different item types or a gap and then stop, and at this point it would be more efficient to swap the loops so it loops through the chest looking for 4 different item types comparing each new item type found against the turtle's inventory.
theoriginalbit #23
Posted 30 January 2013 - 02:08 AM
1. Pick up as many stacks from the input chest as will fit in the inventory
2. Go to the first chest
3. Loop through the turtle's inventory comparing each item against the first few stacks in the chest, say 4 or 8
Please enlighten us as to how it would do this? Given this set of functions in the Turtle API http://computercraft...iki/Turtle_(API)

maybe it could loop through the items until it's found 4 different item types or a gap and then stop, and at this point it would be more efficient to swap the loops so it loops through the chest looking for 4 different item types comparing each new item type found against the turtle's inventory.
I am also interested in how you would go about this.
Edited on 30 January 2013 - 01:10 AM
unobtanium #24
Posted 30 January 2013 - 03:04 AM
The first time i tought about such an sorting turtle, i was like "hum this is easy to do", but the vanilla turtle just doesnt give simple enough commands for such a program. Like TheOriginalBIT allready said, try to try (wtf) it yourself if you can. It is getting very quick very complicated.

Loop through the turtle's inventory comparing each item against the first few stacks in the chest
Thats the problem! You cant check items in a chest without using peripherials or other addons. I want to use the vanilla CC version.

In my version it would be something like this:
Spoiler1.) Turtle sucks in 12 items. 4 slots are free.
2.) Turtle goes to (next) chest.
3.) Turtle takes out the first 4 stacks and put it in the free slots in the turtles inventory.
4.) Check if these items arnt the same
5.a) Take the first item of these and compare all other items with them.
5. B)/> If the two stacks are the same, the slot will be safe in an array.
5.c) Do this for the other three items too.
5.d) You now have an arrays filled with the slot number of the stacks which are the same like the item stacks out of the chest
6.) You now drop the four stacks back into the chest.
7.) You now load the slot numbers from the array and drop these stacks in the turtles inventory
8.) Repeat 2-7 until the inventory is empty or no more (empty) chests are available.
With this, the first four slots of the chests would be allways the same items. However you still have less space for the items the turtle has to sort. On the other hand you dont have as many chests as now, which reduces the travelling of the turtle and less fuelusage.

Like i said i will get into this. Just keep waiting and come back ;D
unobtanium #25
Posted 30 January 2013 - 04:14 AM
Okay guys! It seems i have too much time for this ^^

I finsihed it and made a version now, which can sort up to four items in a single chest.
I added the pastebin links in the first post in the "Other Version"-Section.
I hope you enjoy :D/>
PhilHibbs #26
Posted 30 January 2013 - 04:20 AM
Loop through the turtle's inventory comparing each item against the first few stacks in the chest
Thats the problem! You cant check items in a chest without using peripherials or other addons. I want to use the vanilla CC version.
Aah I see. OK.

Could you… suck the first four slots out of the chest into the turtle's inventory slots 13-16, , loop through 1-12 working out what items to put in the chest, then spit the four comparison stacks back out in the same order they came in, and then spit out the other items that had been identified as matching?
unobtanium #27
Posted 30 January 2013 - 04:56 AM
Could you… suck the first four slots out of the chest into the turtle's inventory slots 13-16, , loop through 1-12 working out what items to put in the chest, then spit the four comparison stacks back out in the same order they came in, and then spit out the other items that had been identified as matching?

Yeah that what i did. Like i explained under the number list :D/>
PhilHibbs #28
Posted 30 January 2013 - 05:01 AM
Ah, yes. I see. I was too busy thinking about the problem to notice that you had posted the same solution. If the chest is sorted and you have 4 stacks of the same thing, I can't see a way of looking for a different stack. Every time you spit a stack out you'll just get the same stack back again won't you? Vertical sorting could work though.
unobtanium #29
Posted 30 January 2013 - 05:43 AM
Okay, one last time in a text instead of points :D/>
The Turtle allways sucks out the first four chest slots and puts them in the slot 13-16. Then it selects the first slot of the turtle inventory. It compares this with all four items out of the chest (13-16). If the item (selected slot) is one or more times identical (with the 13-16), it will put the slot true (array), that means that the stack in the selected slot can be dropped. But before the turtle drops the stack, it checks every slot 1-12. If this is finished, it drops the items in slot 13-16 back into the chests. Every time they will dropped back into the first four slots of the chest. Last but not least, the turtle checks the array which slot can be dropped and which not.
Thats the story behind that!
Btw, if there is an empty chest, the turtle will still drop just one item into it. That means you maybe fill all chests with one, two, three or four items. Otherwise you will have chests with just one item in it again. (You can add more manually later on.) Maybe i will change this, that it drops four. but i am too lazy right now :s
I hope i could help you. If you have other questions rather the item sorting turtle you can send me a message ;D
xInDiGo #30
Posted 30 January 2013 - 05:50 AM
awesome i didn't realize this was being updated! i'll have to give it a go! sucks that i just destroyed half my chest room w/ a portal gun -.- (& now i can't log in cause i'm stuck in the void)

BTW you must be a major AVATAR fan eh unobtanium?
unobtanium #31
Posted 30 January 2013 - 07:42 AM
Haha! Dat portal gun ;D

Yes, but the material UNOBTANIUM exists in many films, most sci-fi, because of its non-existence :P/>
remiX #32
Posted 04 February 2013 - 05:19 AM
Nice work :P/>
unobtanium #33
Posted 04 February 2013 - 06:02 AM
Haha! Hello there and thank you ;D
PhilHibbs #34
Posted 10 February 2013 - 05:29 AM
"Unobtanium" as been a joke phrase in sci if fandom for a long time, for any impossible super-material. There's been a couple of films recently that actually used the term, "Core" I think is one.
unobtanium #35
Posted 10 February 2013 - 06:01 AM
Well, i thank you for pushing my thread with some off-topic :D/>
But you are right. On wikipedia is a nice explanation about Unobtanium, too!
Mild7 #36
Posted 22 February 2013 - 09:44 AM
I am having difficulty installing and running the sorting program that places up to 4 items per chest.

Would someone please offer the command I type in to the turtle to install and run this version. Thank you.
unobtanium #37
Posted 22 February 2013 - 12:06 PM
I dont know how you installed the code :D/>
If you enabled the http api you can get it with the link (the end odd one with all the numbers and letters) and put this into
pastebin get <link> <name>
The name you can choose yourself. This is what you have to tipe into the turtle to start the program.
However, you also can copy the whole code (works at the bottom with the raw code at pastebin) and paste it into a text document on your computer. Name it (this is what you have to tipe into the turtle or computer) and safe it without an ending e.g. "NameOfTheProgram". Not "NameOfTheProgram.txt"!!!!!
Put the files into …yourMinecraftDirection\mods\ComputerCraft.zip\lua\rom\programs\turtle
or …yourMinecraftDirection\mods\ComputerCraft.zip\lua\rom\programs\computer
That should do it. I hope that was helpful. If not there are some tutorials about this too ;D
Mild7 #38
Posted 22 February 2013 - 12:58 PM
I was able to run pastebin get hcwy8SQ2 ist on my turtle and execute ist and build a structure, but it only sorted 1 item per chest.

With the turtle still in the structure, I was able to download 6kENkkFL and tkTgfCkJ, but both gave errors when trying to execute.

Does the sorter have to build the structure? Are there any parameters when running the newer 4 item sorting programs from the turtle?

Thank you for sharing the program and for the assistance.
unobtanium #39
Posted 23 February 2013 - 06:10 AM
hcwy8SQ2 is the normal program in which the turtle just will sort one item in each chest.
6kENkkFL is for the turtle if you use rednet.

tkTgfCkJ is the program you want to use for sorting UP TO FOUR items in a single chest.
In empty chests it still will drop just one item instead of four.
You still have to put your items in the chest yourself if you want to have more then one type of item in chest. You can change the indicator items everytime. The first four stacks/slots in every chest (the top left ones) are used as indicators.
For building the structure you just have to say how many chests you want to have horizontal and then how many chests you want vertically. Its the same program used for the normal program.
I hope that helped and fix your bugs ;D
xInDiGo #40
Posted 09 March 2013 - 07:02 PM
is ITEMS SORTING TURTLE BETA 0.4.1+ working? when i run it i get an error :[

using this one - http://pastebin.com/6kENkkFL
unobtanium #41
Posted 09 March 2013 - 11:23 PM
Thank you! I added this "then" and it should work fine now.
Devoto #42
Posted 12 March 2013 - 07:41 AM
Im getting an bios:338: [string "THENAMEOFMYPROGRAM"]263: 'then' expected when i try to run the tkTgfCkJ on the turtle :/
And as far as i understand i need to have that working to be able to run the computer program and then control my turtle from there?

Im kinda new to this whole rednet thing, do i need to do something else to other then installing the computer script on the computer and the rednet turtle script on the turtle to be able to control the sorting from the computer?
unobtanium #43
Posted 12 March 2013 - 09:59 AM
I should have fixed the error.

That's right! Then you have to start both programs and select from the computer menu what you want. You can use the single program without rednet if it confuses you. Then you just have the turtle program with the menu.
44shades44 #44
Posted 15 March 2013 - 02:50 AM

Sort Programs for the computer: isc still the same! Use the program above!
I don't mean to be a gramma/typo nazi, but is that meant to be "is still the same!"?

Big fan of your programs.
unobtanium #45
Posted 15 March 2013 - 05:28 AM
:D/> With isc i mean the program name i gave it in pastebin. I added some brackets and i added a "is", which was missing. Hope it sounds fine now :P/>

Well, thank you. Stay tuned in some weeks i might release another program.
Andydrummmer #46
Posted 11 June 2013 - 07:44 PM
It keeps going nil on line 170 for me. I tried it on 2 servers and in single player.
unobtanium #47
Posted 12 June 2013 - 06:18 AM
Did you turned fuel usage off? Which program are you using?