13 posts
Posted 17 June 2014 - 08:12 PM
I have been scouring these forums, reddit, and google for the last few days on documentation for narcissistic turtles. It doesn't exist. However, I've found some helpful code snips to get methods from wrapped peripheral inventories.
The one thing I have not been able to find a whisper of is how do you apply the same methods for inventories against the same turtle? There was a post referencing that the turtle could be aware of its own inventory. There was also a post suggesting you could "wrap a narcissistic peripheral" to get at the turtle's inventory, but that doesn't make sense.
Given that Mikeemoo repeatedly has stated that the narcissistic turtle can query itself, can someone give me a one or two line example of HOW? I can figure out the wrapped inventories, but can't get any information on how to do it to the turtle itself.
For example, if I chopped down 5 different trees and had 5 different chests for each type of wood, how can I scan the turtle's inventory and determine which slot has which type of wood so I can put it into the correct chest?
Edited on 17 June 2014 - 06:20 PM
227 posts
Location
Germany
Posted 17 June 2014 - 08:32 PM
I suppose you don't really have much experience in CC yet.
You could give
that a read.
Listed in there is
peripheral.getMethods(). With that you will get all available functions of that peripheral, in this case the narcissistic peripheral or whatever.
By going in the lua prompt and typing in
textutils.serialize(peripheral.getMethods("left")) you would get all functions.
See getAllStacks or getStackInSlot?
Both will return a table with the information about the items in the turtle, where getAllStacks would basically return a table with all the items available.
If there is wood in slot 1, the following code would return the type of wood:
a = peripheral.wrap("left")
b = a.getStackInSlot(1)
print(b.name) --# e.g. "Spruce Wood"
print(b.rawName) --# e.g. "tile.log.spruce"
Hope this helped.
~wieselkatze
Edited on 17 June 2014 - 06:33 PM
13 posts
Posted 17 June 2014 - 08:36 PM
I suppose you don't really have much experience in CC yet.
You could give
that a read.
I do not want to run getStackInSlot against the peripheral on the left. I want to run getStackInSlot against slot 1 of the turtle that the program is running on.
Pretend there is nothing else on the map except just the turtle and stuff in its inventory slots. How can I figure out what it has in its inventory slots?
Edited on 17 June 2014 - 06:48 PM
227 posts
Location
Germany
Posted 17 June 2014 - 08:47 PM
Ah okay, I got it now. You can't check the turtle's inventory if it isn't a narcissistic turtle.
By putting a duck antenna and a turtle in the crafting grid, you will get one, but otherways it is not possible to check the turtle's inventory.
The code I posted an all the available functions are only there if you actually use a narcissistic turtle.
Edited on 17 June 2014 - 06:48 PM
13 posts
Posted 17 June 2014 - 08:58 PM
… I
am using a narcissistic turtle (the subject of the post?)
I already tried applying those methods against the turtle but they don't work. From a test program on a turtle with a block of coal ore in slot 1:
moo = turtle.getStackInSlot(1)
print(moo.name)
>test
test:1: attempt to call nil
227 posts
Location
Germany
Posted 17 June 2014 - 09:05 PM
Yea, thats exactly what I posted above. The narcissistic turtle is a turtle equipped with the peripheral.
It has nothing to do with the turtle API.
As I said, wrap the peripheral and use that wrapper.
When you look at the turtle, you will se that little box at the left (the peripheral).
Instead of giving sarcastic answers, you could try out what I tried to explain to you.
Edited on 17 June 2014 - 07:08 PM
13 posts
Posted 17 June 2014 - 09:13 PM
What was sarcastic about it?
The concept of making a turtle with the antenna and that antenna being *equipped* is not explained very well (not necessarily by you, just in general). In my mind it's trying to grab the info from a chest on the left like normal turtles/cc would, which is why I haven't tried that. Quite confusing.
I will try this, thanks.
8543 posts
Posted 17 June 2014 - 10:06 PM
No, there can be only one peripheral on a given side. If the narcissistic peripheral is on the left, it cannot access any chests as peripherals on that side, only the narcissistic peripheral.
656 posts
Posted 18 June 2014 - 05:53 AM
If you craft a peripheral with a turtle, it gets put on the side of the turtle. You can just wrap the peripheral at the side you see the peripheral on.