I've done a bit of research and couldn't find much. Could someone explain how I use the chat box from moarperipherals? Just basic stuff, like what someone's saying, and how to make the chat box say things too.


(MoarPeripherals) Chat Box help needed
Started by NegativeVoltage, Dec 01 2015 11:57 PM
1 reply to this topic
#1
Posted 01 December 2015 - 11:57 PM
#2
Posted 02 December 2015 - 12:32 AM
These days, the closest thing to "documentation" remaining would be the source of the blocks here.
In brief, though, when the Chat Box detects a player using chat, it'll generate an event which can be pulled like so:
If a player starts their chat message with ##, then only chat boxes will "see" it (you get a "chatbox_command" event instead of a "chat_message" event). Certain other happenings - such as player deaths - also generate events; I like to use this basic loop to give me information about events I'm unfamiliar with:
Chat boxes can be made to speak by wrapping them and then calling their "say" function:
If you want to use private messages, use "tell":
It's fairly simple, but I've also got this example script that I wrote for use with this API.
Keep peripheral.getMethods() in mind for finding more functions.
There are also "admin" chatboxes available only in the creative inventory. Regular ones are range-limited, subject to the MoarPeripherals config file; admin ones aren't, and if memory serves, they can even generate events letting you know when players join/leave the server.
In brief, though, when the Chat Box detects a player using chat, it'll generate an event which can be pulled like so:
local event, chatBoxSide, playerName, message = os.pullEvent("chat_message")
If a player starts their chat message with ##, then only chat boxes will "see" it (you get a "chatbox_command" event instead of a "chat_message" event). Certain other happenings - such as player deaths - also generate events; I like to use this basic loop to give me information about events I'm unfamiliar with:
while true do print(os.pullEvent()) end
Chat boxes can be made to speak by wrapping them and then calling their "say" function:
local myChatBox = peripheral.wrap(chatBoxSide) myChatBox.say("Hello world")
If you want to use private messages, use "tell":
myChatBox.tell("NegativeVoltage", "Hello")
It's fairly simple, but I've also got this example script that I wrote for use with this API.
Keep peripheral.getMethods() in mind for finding more functions.
There are also "admin" chatboxes available only in the creative inventory. Regular ones are range-limited, subject to the MoarPeripherals config file; admin ones aren't, and if memory serves, they can even generate events letting you know when players join/leave the server.
Edited by Bomb Bloke, 02 December 2015 - 12:38 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users