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

[Question] Getting the label of a peripheral

Started by BluSunrize, 31 January 2013 - 10:04 AM
BluSunrize #1
Posted 31 January 2013 - 11:04 AM
Heya!

I've got a question: Is it possible to get the label of a "peripheraled"-computer, without that computer having to do anything?

I've tried simply wrapping it and then using getComputerLabel(), but that didn't work.
My plan is to have a turtle that will be able to get the label of any other turtle or computer placed next to it, archive it (it's my first work with the fs API), break it and transfer it into storage. (The label will then later be used for create a list of all sorted machines)


So, back to the original question: Is it possible to get the label of a computer by designating him as a peripheral?


Thanks in advance
OmegaVest #2
Posted 31 January 2013 - 11:26 AM
That would be a no, I believe. However, you can use peripheral.getMethods(side) to check it if you want, because I'm not sure, but that is a good way to check what a peripheral can do (aside from events).


Edit: Also, check here. The best you can do is getComputerID. DIsks, you can get the labels off of, though.
Doyle3694 #3
Posted 31 January 2013 - 11:51 AM
an even better way for any table to get its content(behind the scenes wrapped stuff, loaded API's and stuff like that are tables):

tRandom = {"this","is", "a", "RANDOM", "table", 1337}
for i in pairs(tRandom) do
   print(i)
end
BluSunrize #4
Posted 02 February 2013 - 07:58 AM
Well I've found a way. A disk drive with a disk that has a startup file. This disk forces the computer or turtle to get its own label and then name the disk like that.
The turtle responsible for sorting it then gets the disk's label and by that the computer's label.
OmegaVest #5
Posted 02 February 2013 - 08:27 AM
Well. . . that's creative. Good on you.