summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chat.lua34
1 files changed, 30 insertions, 4 deletions
diff --git a/chat.lua b/chat.lua
index 14d1334..3e82ade 100644
--- a/chat.lua
+++ b/chat.lua
@@ -5,7 +5,8 @@ assert(M,"no monitor")
M.setTextScale(0.5)
local Mw,Mh = M.getSize()
-local lbw = 4+16+10
+local scorewidth=10
+local lbw = 4+16+scorewidth
local wLog = window.create(M,1,1,Mw-lbw,Mh)
-- wLog.setBackgroundColor(colors.blue)
-- wLog.clear()
@@ -31,18 +32,43 @@ end
-- lb
local function draw_lb(W,scores)
+ local w,h = W.getSize()
W.setBackgroundColor(colors.gray)
W.clear()
- -- numbers
+ -- line numbers
W.setTextColor(colors.yellow)
for line=1,10 do
- W.setCursorPos(1,line)
+ W.setCursorPos(1,line+1)
W.write(pad_r(line,2)..".")
end
+
+ -- actual scores
+ local thescores = {}
+ for name,score in pairs(scores) do
+ table.insert(thescores,{name=name,score=score})
+ end
+ table.sort(thescores,function(a,b) return a.score < b.score end)
+ for i=1,10 do
+ local name,score = thescores[i].name, thescores[i].score
+ -- name
+ W.setTextColor(colors.white)
+ W.setCursorPos(5,i+1)
+ W.write(name)
+ -- score
+ W.setTextColor(colors.blue)
+ W.setCursorPos(w-scorewidth,i+1)
+ W.write(pad_r(score,scorewidth))
+ end
end
-draw_lb(wLb,nil)
+draw_lb(wLb,{
+ aaa=10
+ bbb=100
+ ccc=12345
+ ddd=234287
+ thethethethe=69420
+ harold=111222})
local function score(msg)