summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-08-04 03:56:41 +0100
committerubq323 <ubq323@ubq323.website>2022-08-04 03:56:41 +0100
commit2e2714520bb95ef6a89cf0303ea469bef5e86f36 (patch)
tree57683ec3e900c46a3f0998adce41de5cc961d2a7
parent5b3a392330bd2c63e68f50d2c6abcaf8e8e0f3a2 (diff)
chat
-rw-r--r--chat.lua31
1 files changed, 25 insertions, 6 deletions
diff --git a/chat.lua b/chat.lua
index eecd88a..0b9cd73 100644
--- a/chat.lua
+++ b/chat.lua
@@ -26,12 +26,6 @@ local wLb = window.create(M,Mw-lbw+1,1,lbw,11)
-- utils
-local function p(thing,...)
- local o=term.redirect(thing)
- print(...)
- term.redirect(o)
-end
-
local function pad_r(s,width)
return string.rep(" ",width-#tostring(s))..s
end
@@ -111,6 +105,31 @@ local function draw_lb(W,scores)
end
end
+-- logging
+local function log_msg(W,user,text,score)
+ local w,h = W.getSize()
+ W.scroll(1)
+ W.setCursorPos(1,h)
+
+ local function st(c) W.setTextColor(c) end
+ local function wr(t) W.write(t) end
+
+ st(colors.white) wr"<" st(colors.orange) wr(user) st(colors.white) wr"> ("
+ st(colors.cyan) wr(score) st(colors.white) wr(") ") st(colors.lightGray)
+
+ local x,y = W.getCursorPos
+ local remsp = w-x+1
+ if remsp >= 3 then
+ if #text > remsp then
+ text = text:sub(1,remsp-3).."..."
+ end
+ wr(text)
+ end
+end
+
+
+
+
-- persistence
local function save_scores(scores)
local file,err = fs.open(".chatscores","w")