ComputerCraft Archive

readChat

computer utility Vexatos github

Description

My Computercraft program collection

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/Vexatos/ComputerCraft-Programs/master/Main/chatFloppy/readChat.lua readchat
Archive:wget https://cc.shobie.xyz/cc/get/gh-Vexatos-ComputerCraft-Programs-main-chatfloppy-readchat readchat
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-Vexatos-ComputerCraft-Programs-main-chatfloppy-readchat readChat

Usage

Run: readChat

Tags

none

Source

View Original Source

Code Preview

os.loadAPI(direct .. "/apis/util")
chattbl = {}

chat, chatSide = util.getPeripheral("chat")
if chat == nil then
  print("No Chat peripheral found")
  return
end

print("Using Chat peripheral on "..chatSide)
print("Reading chat...")
print("")

while true do
event,player,message = os.pullEvent("chat")
write("[d".. os.day() .. "," .. textutils.formatTime(os.time(),true) .. "]")
print(player .. "> " .. message)
chattbl[#chattbl+1] = "[d".. os.day() .. "," .. textutils.formatTime(os.time(),true).. "]" .. player .. "> " .. message
end