Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chatBox = peripheral.find("chatBox")
- local playerName = "<YOUR PLAYER NAME HERE>"
- local enabled = false
- -- Sets what side a redstone signal is required to enable/disable
- while true do
- local signal = redstone.getInput("right")
- if signal and not enabled then
- enabled = true
- print("Enabled")
- elseif not signal and enabled then
- enabled = false
- print("Disabled")
- end
- if enabled then
- local event, player, message = os.pullEvent("chat")
- local username = string.match(player, "%[(.-)%]")
- if username and string.find(message, playerName) then
- chatBox.sendMessageToPlayer(username, "YOUR MESSAGE HERE")
- end
- end
- os.sleep(0.1) -- Wait for a short time before checking again
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement