Jump to content




(MoarPeripherals) Chat Box help needed


1 reply to this topic

#1 NegativeVoltage

  • New Members
  • 1 posts
  • LocationWouldn't you like to know

Posted 01 December 2015 - 11:57 PM

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.

#2 Bomb Bloke

    Hobbyist Coder

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

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:

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