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

Regarding Openperipheral

Started by BlueMond, 22 September 2013 - 03:40 PM
BlueMond #1
Posted 22 September 2013 - 05:40 PM
I've been messing around with OpenPeripheral and on the documentation for the glasses bridge terminal it shows that when you create an item that you said set* a variable equal to the method used for creating the item. In the example, the variable is called objectInfo. I want to know if you can actually obtain any info from the object using this variable such as something like "print(objectInfo.text)" if the object was text.

thePeripheral = peripheral.wrap("direction")

objectInfo = thePeripheral.addText(x, y, text, color)
print(objectInfo.text)
Vindex #2
Posted 22 September 2013 - 06:11 PM
Don't have time for testing this, but try:

for i,_ in pairs(objectInfo) do
  print(i)
end

This will print API/contents of objectInfo.
ElvishJerricco #3
Posted 22 September 2013 - 06:33 PM
Most of the properties about anything you add to the screen have setter and getter functions in those objects. So you can get and change the text of a text object with objectInfo.getText() and objectInfo.setText("text")
BlueMond #4
Posted 22 September 2013 - 07:12 PM
Thank you both. I knew there was some way to get the contents of it but I did not remember how and I also forgot that you should use get and set with such a thing.