Jump to content




Followed a tutorial perfectly, got no errors, but didnt get the desired effect

help peripheral

6 replies to this topic

#1 Cloud Ninja

  • Members
  • 361 posts

Posted 15 March 2015 - 03:42 AM

So i wanted to use chatboxes and i found a tutorial, and had the EXACT code he had, and it didnt work at all. Can anyone tell me how to pull the chat?

such as:
chat = peripheral.wrap("left")
while true do
event,player,message = os.pullEvent("chat")
print(player,":  ",message)
end


#2 valithor

  • Members
  • 1,053 posts

Posted 15 March 2015 - 04:12 AM

What peripheral mod are you using (that determines the answer)?

Chances are the event name is not "chat" or it has changed between versions, so you will have to change that to match what the event name is. You could figure this out by going into the lua program, and typing os.pullEvent(), and then typing something in chat. The first thing it returns would be the event name.

#3 Cloud Ninja

  • Members
  • 361 posts

Posted 15 March 2015 - 04:27 AM

View Postvalithor, on 15 March 2015 - 04:12 AM, said:

What peripheral mod are you using (that determines the answer)?

Chances are the event name is not "chat" or it has changed between versions, so you will have to change that to match what the event name is. You could figure this out by going into the lua program, and typing os.pullEvent(), and then typing something in chat. The first thing it returns would be the event name.
Ohai Val. Im using the one on your server, MoarPeriphs

#4 valithor

  • Members
  • 1,053 posts

Posted 15 March 2015 - 05:09 AM

View PostCloudNinja, on 15 March 2015 - 04:27 AM, said:

View Postvalithor, on 15 March 2015 - 04:12 AM, said:

What peripheral mod are you using (that determines the answer)?

Chances are the event name is not "chat" or it has changed between versions, so you will have to change that to match what the event name is. You could figure this out by going into the lua program, and typing os.pullEvent(), and then typing something in chat. The first thing it returns would be the event name.
Ohai Val. Im using the one on your server, MoarPeriphs

In that case the event you are looking for is actually "chat_message". The way os.pullEvent works when you pass it a argument is it only looks for a event that matches the event you passed to it, and will discard all the others.

Didnt even make the association we were both on the server when i posted that...

Edited by valithor, 15 March 2015 - 05:10 AM.


#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 15 March 2015 - 05:23 AM

... and the full parameters of the event would be event, side, player then message.

http://moarperiphera...p?title=ChatBox

#6 biggest yikes

  • Members
  • 573 posts

Posted 18 March 2015 - 08:10 PM

Your code is off a little, here's the "correct" version (with MorePeripherals):
local chat = peripheral.wrap("left")
while true do
	event, side, player, message = os.pullEvent("chat_message")
	print(player,":  ",message)
end
First of all, the event you're looking for is "chat_message", not "chat". We only use the "chat" variable for calling functions; not for events. The string as the first argument in "os.pullEvent" is a filter, so it would discard the event "chat_message" if we were looking only for "chat".
Second of all, the second parameter is not the player, but the side. Add "side," after "event," and you've got that part down.

Edited by Atenefyr, 18 March 2015 - 08:12 PM.


#7 valithor

  • Members
  • 1,053 posts

Posted 18 March 2015 - 08:52 PM

View PostAtenefyr, on 18 March 2015 - 08:10 PM, said:

Your code is off a little, here's the "correct" version (with MorePeripherals):
local chat = peripheral.wrap("left")
while true do
	event, side, player, message = os.pullEvent("chat_message")
	print(player,":  ",message)
end
First of all, the event you're looking for is "chat_message", not "chat". We only use the "chat" variable for calling functions; not for events. The string as the first argument in "os.pullEvent" is a filter, so it would discard the event "chat_message" if we were looking only for "chat".
Second of all, the second parameter is not the player, but the side. Add "side," after "event," and you've got that part down.

Really nice when people restate what the people who had already answered said 4+ days earlier.

Edited by valithor, 18 March 2015 - 08:52 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users