diff options
author | ubq323 <ubq323@ubq323.website> | 2022-08-04 02:21:42 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2022-08-04 02:21:42 +0100 |
commit | 4e6d4d25d72d0c0a8bd4cc3df6d865eab338aed9 (patch) | |
tree | f646315302587819eb7aebb0a5e86dc0ba780003 | |
parent | df56e3fbe957bfff99a4c567b8079b2a01cbba3c (diff) |
chat
-rw-r--r-- | chat.lua | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -1,12 +1,24 @@ local man = peripheral.find"manipulator" assert(man and man.hasModule"plethora:chat","no chat thing") -local m = peripheral.find"monitor" -assert(m,"no monitor") +local M = peripheral.find"monitor" +assert(M,"no monitor") -local function p(...) - term.redirect(m) +M.setTextScale(0.5) +local Mw,Mh = M.getSize() +local lbw = 4+16+10 +local wLog = window.create(M,1,1,Mw-lbw,Mh) +wLog.setBackgroundColor(colors.blue) +wLog.clear() +wLog.write("LOG") +local wLb = window.create(M,Mw-lbw+1,1,lbw,11) +wLb.setBackgroundColor(colors.red) +wLb.clear() +wLb.write("LB") + +local function p(thing,...) + local o=term.redirect(thing) print(...) - term.redirect(term.native()) + term.redirect(o) end local function score(msg) @@ -15,10 +27,13 @@ local function score(msg) return s end +local userscores = setmetatable({},{__index=function()return 0 end}) + while true do local _,user,msg = os.pullEvent"chat_message" local s = score(msg) - p(string.format("(%d) <%s> %s",s,user,msg)) + userscores[user] = userscores[user] + s + p(M,string.format("(%d) <%s> %s",s,user,msg)) end |