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

Peripherals problem(using terminal glasses bridge)

Started by Hellreaper, 22 April 2016 - 10:07 PM
Hellreaper #1
Posted 23 April 2016 - 12:07 AM
I am trying to get peripherals going and read and write to chat since I saw it was possible.
But none of the peripheral functions work. I tried to get OpenPeripherals to make a UI with the glasses…
I simply get no result and I dont know why.

As I read on the wiki and trying stuff out I found out that you can read and write to the chat but no luck so far…


p = peripheral.wrap("bottom")
event, player, message = os.pullEvent("chat")
while true do
if message == hi then
p.say("test")
end
end
KingofGamesYami #2
Posted 23 April 2016 - 12:37 AM
You should move the os.pullEvent call into the loop.
Dog #3
Posted 23 April 2016 - 12:41 AM
Also, you're comparing the variable message to a variable named hi (which is undefined and will be nil), not to the string "hi" - it should look like this

if message == "hi" then
Edited on 22 April 2016 - 10:43 PM
Hellreaper #4
Posted 23 April 2016 - 01:14 AM
I did both after reading what you guys said (no errors or anything, just nothing happening in general)
but that didn't fix it… In case it would matter I am running on FTB Infinity Evolved v2.5.0
KingofGamesYami #5
Posted 23 April 2016 - 01:29 AM
In that case, nothing is generating a chat event with the message "hi" (or the peripheral isn't saying anything in chat). I recommend printing every chat event received.

local p = peripheral.wrap("bottom")
while true do
  local event, player, message = os.pullEvent("chat")
  print( message )
end
valithor #6
Posted 23 April 2016 - 02:02 AM
What peripheral mod are you using to try and send/receive the chat messages? The filter for the event name is different depending on mod.

iirc "chat" is for miscperipherals, and "chat_message" is for moarperipherals. I do not think anything from openperipherals can actually send messages, so it is probably not what you are looking for.
Edited on 23 April 2016 - 12:04 AM
Hellreaper #7
Posted 23 April 2016 - 12:15 PM
What peripheral mod are you using to try and send/receive the chat messages? The filter for the event name is different depending on mod.

iirc "chat" is for miscperipherals, and "chat_message" is for moarperipherals. I do not think anything from openperipherals can actually send messages, so it is probably not what you are looking for.

Im running on openperipherals. And pulling the chat event is probably not working, I will try and look at the api if im using the wrong term
valithor #8
Posted 23 April 2016 - 09:48 PM
What peripheral mod are you using to try and send/receive the chat messages? The filter for the event name is different depending on mod.

iirc "chat" is for miscperipherals, and "chat_message" is for moarperipherals. I do not think anything from openperipherals can actually send messages, so it is probably not what you are looking for.

Im running on openperipherals. And pulling the chat event is probably not working, I will try and look at the api if im using the wrong term

From what I found openperipherals does not support sending messages, so I doubt there is a say function in the peripheral. Also, it appears the event name is "glasses_chat_message" instead of "chat". I would suggest going into the lua program, and running this code and then say something in chat to see what the order it returns the information is in.


print(textutils.serialize({os.pullEvent("glasses_chat_message")}))

If this doesn't work, then the information about the filter that I found was wrong, so instead do something like this:

while true do
 print(textutils.serialize({os.pullEvent("glasses_chat_message")}))
end

And then say something in chat, and it will show you what the event name is along with the order it returns in.