374 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
1023 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.
374 posts
Posted 15 March 2015 - 04:27 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.
Ohai Val. Im using the one on your server, MoarPeriphs
1023 posts
Posted 15 March 2015 - 05:09 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.
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 on 15 March 2015 - 04:10 AM
7083 posts
Location
Tasmania (AU)
Posted 15 March 2015 - 05:23 AM
… and the full parameters of the event would be event, side, player then message.
http://moarperipherals.com/index.php?title=ChatBox
673 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 on 18 March 2015 - 07:12 PM
1023 posts
Posted 18 March 2015 - 08:52 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.
Really nice when people restate what the people who had already answered said 4+ days earlier.
Edited on 18 March 2015 - 07:52 PM