summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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")