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

[Lua][misc peripherals][interactive sorter] help understanding commands

Started by detsuo04, 23 May 2013 - 08:32 PM
detsuo04 #1
Posted 23 May 2013 - 10:32 PM
So i have read every document i can find on this device as well as coppied other peoples code for it and i still cant make this thing work. I always get a nil value or an error or the line table:"giberish" anyway i am trying to use this device to send items through pneumatic tubes into one of several chests and I am trying to start by geting it to print the data it gathers about an item or stack in its inventory. if i can do at least that much i can calibrate it to sort automatically.

I can't seem to make the commands for this device do anything except spit out errors. The only one that i can make do anything at all is
peripheral.wrap("bottom") which outputs table: "giberish"

If anyone can help me understand this darn thing i would greatly appreciate it.

I would post specific errors but i have seen them all as i have spent a few ours messing with it and a few more trying to make other peoples programs work.

Thanks for your time.
W00dyR #2
Posted 24 May 2013 - 07:01 AM
First thing, the interactive sorter doesn't output in tubes, only buildcraft pipes or inventories.

If an item enters it, it emits the event "isort_item" like this:


event, itemID, ammount = os.pullEvent()

So if you then wrap it, and use its functions to sort items, you can sort items that enter it like the following:


s = peripheral.wrap("left") -- or any other side
direction = 1 -- Or any other number, read the miscPeripherals topic for the directions
while true do
  event, itemID, amount = os.pullEvent()
  s.sort(direction, amount)
end
And if you want it to print the information about the item that enters, simply add this into the while loop

print(itemID)
print(amount)


If you want specific directions for certain items to go in, then you can make a table, and have it check the table for matches and stuff, if its a match go direction 1, if not, go direction 5 or something similiar. I have my own system set up which reads items from a website link, depending on its response, it sends it to different directions. Yes, this means that it doesn't know the items name, what kind of item it is, or anything, only the itemID of the item. So if you want specific sort directions, you must have a table or system where it gathers this information from.
detsuo04 #3
Posted 24 May 2013 - 02:16 PM
ok I see. I appreciate the help here. I was having a language issue. I couldn't understand how to incorporate the wrap with the command like you did with s.sort()

I can work out the logic but I have so much trouble learning the keywords and how to fit them together.

On a side note do you have time to go over how to print data in an imbedded table?

for example if i had the device scan an inventory and provide the info on all items within, i can have it build a table containing tables for each item with the three fields for each item and i want it to print the stack size of one specific item. printing a field on the bottom level so to speak.

and can the interactive sorter scan an inventory if they are connected with a BC pipe?