diff options
author | ubq323 <ubq323@ubq323.website> | 2022-08-04 02:37:04 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2022-08-04 02:37:04 +0100 |
commit | 39f403e0639637b691778e49c2a1929c09864fc3 (patch) | |
tree | f1bde2a23c074dc3369bd5d8fca77ec22b7b1f41 | |
parent | 493051411c6f2376b7de9bcde10d1d90b575c7a3 (diff) |
chat
-rw-r--r-- | chat.lua | 34 |
1 files changed, 30 insertions, 4 deletions
@@ -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) |