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

[DW20 1.0.0][CC 1.57][MC 1.6.4] Trying to pull/push an item into a chest

Started by MisterBrownZA, 12 December 2013 - 04:39 PM
MisterBrownZA #1
Posted 12 December 2013 - 05:39 PM
Greetings fellow ComputerCrafters,

Since I can't find this issue anywhere on the forums, I've decided to go ahead and register and create a new topic.

I've been trying to replicate the code used by DW20 for the crystal portal as seen in his series.

I've been having issues when issuing the "pullItem" or "pushItem" commands with the following error: Target direction is not a valid inventory

I've put a chest at each direction, except for "south"

Here's my code:


chest = peripheral.wrap('top')
info = chest,getInventorySize()
print(info)
chest.pushItem('up',1,1)

My trial and error code testing does extend a lot more, so that's the summarized version.

Can anyone help me out ?
gezepi #2
Posted 12 December 2013 - 07:11 PM
This looks like something that I have run into in the past. When you push/pull a stack it is from the perspective of the chest. If your program is running from a turtle that has a chest above it then you attach it as you did (with 'top') then when you move stacks around you are telling the chest to do it so use 'down' because the turtle is below the chest (or is it 'bottom'? I can never remember).
theoriginalbit #3
Posted 12 December 2013 - 07:55 PM
I've been having issues when issuing the "pullItem" or "pushItem" commands with the following error: Target direction is not a valid inventory
Its a fairly simple error really, it means that there is no inventory in the target direction (i.e. the first argument). with the code you're using you have to make sure the inventory is on top of the chest. Valid directions are north, south, east, west, up, down.

Assuming that there is (what you think) an inventory on the top, you must make sure that OpenPeripheral/Minecraft sees it as an inventory, the easiest method of doing this is to place a computer next to it and make sure it has the same methods as the chest.

If both of these are correct you're going to have to supply more information, including, but not limited to, screenshots of the setup.
Edited on 12 December 2013 - 06:55 PM
MisterBrownZA #4
Posted 12 December 2013 - 11:05 PM
@Gezepi, Thanks for the info, mate.

@TheOriginalBit, You know, I spent waay too much time trying to trouble shoot this last night [in comparison to the code above, my testing program was 23 lines of code]. Somehow, what you said worked. . . So I'm an idiot.

Thanks for the help guys!