summaryrefslogtreecommitdiff
path: root/chat.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-08-04 02:37:04 +0100
committerubq323 <ubq323@ubq323.website>2022-08-04 02:37:04 +0100
commit39f403e0639637b691778e49c2a1929c09864fc3 (patch)
treef1bde2a23c074dc3369bd5d8fca77ec22b7b1f41 /chat.lua
parent493051411c6f2376b7de9bcde10d1d90b575c7a3 (diff)
chat
Diffstat (limited to 'chat.lua')
-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)