(prepare to cringe at the layout)
cbox = peripheral.wrap("right")
local T = os.time()
local D = os.day()
while true do
event, player, message,command = os.pullEvent("chat")
if message == "Time?" then
cbox.say(string.char(167).."6"..string.char(167).."l".."The time is "..textutils.formatTime( T, false ).." on Day "..D)
end
end
So once I did that I figured I could do something like this, using surferpup's Real World Time API.
os.loadAPI("timeAPI")
cbox = peripheral.wrap("right")
local T = os.time()
local D = os.day()
while true do
event, player, message,command = os.pullEvent("chat")
if message == "Time in-game?" then
cbox.say(string.char(167).."6"..string.char(167).."l".."The time is "..textutils.formatTime( T, false ).." on Day "..D)
end
local uTime = timeAPI.getTime("UTC",0,dateTimeFormat,0)
if message == "UTC Time?" then
cbox.say("The time is: "..uTime)
end
end
Now, whenever a lazy person wants to know the time in UTC, all they have to do is type it in chat mid-conversation, as opposed to having to tab out to google it like a normal person. However, it will get extremely annoying if every time someone asks the chatbox for the time, it will flood the chat with information that is only relevant to two people at most at any given moment. I am aware that chatboxes can tell(), but I just can not figure out how to get the Chat Box to detect who asked for the time and tell() them instead of perpetually annoying the rest of the server by riddling say()'ing to everyone what one person asked for.
I would appreciate if someone could point me in the right direction.