summaryrefslogtreecommitdiff
path: root/chat.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-08-04 02:55:14 +0100
committerubq323 <ubq323@ubq323.website>2022-08-04 02:55:14 +0100
commitc7090b9381cda803fb314f2d95ee62812712e9b6 (patch)
tree33ccce9292f2580adabadd3b1898c137c55619f2 /chat.lua
parent5bfe7c3c9a100332a952cc211e41d174b1206c83 (diff)
chat
Diffstat (limited to 'chat.lua')
-rw-r--r--chat.lua30
1 files changed, 17 insertions, 13 deletions
diff --git a/chat.lua b/chat.lua
index 6e44d56..879d630 100644
--- a/chat.lua
+++ b/chat.lua
@@ -8,10 +8,10 @@ M.clear()
local Mw,Mh = M.getSize()
local scorewidth=10
local lbw = 4+16+scorewidth
-local wLog = window.create(M,1,1,Mw-lbw,Mh)
--- wLog.setBackgroundColor(colors.blue)
--- wLog.clear()
--- wLog.write("LOG")
+local wLog = window.create(M,1,12,Mw,Mh-12)
+ wLog.setBackgroundColor(colors.blue)
+ wLog.clear()
+ wLog.write("LOG")
local wLb = window.create(M,Mw-lbw+1,1,lbw,11)
-- wLb.setBackgroundColor(colors.red)
-- wLb.clear()
@@ -60,7 +60,7 @@ local function draw_lb(W,scores)
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)
+ table.sort(thescores,function(a,b) return a.score > b.score end)
for i=1,10 do
if not thescores[i] then break end
@@ -76,13 +76,7 @@ local function draw_lb(W,scores)
end
end
-draw_lb(wLb,{
- aaa=10,
- bbb=100,
- ccc=12345,
- ddd=234287,
- thethethethe=69420,
- harold=111222,})
+draw_lb(wLb,)
local function score(msg)
@@ -91,9 +85,19 @@ local function score(msg)
return s
end
-local userscores = setmetatable({},{__index=function()return 0 end})
+
+
+local userscores = setmetatable({
+ aaa=10,
+ bbb=100,
+ ccc=12345,
+ ddd=234287,
+ thethethethe=69420,
+ harold=111222,
+},{__index=function()return 0 end})
while true do
+ draw_lb(wLb,userscores)
local _,user,msg = os.pullEvent"chat_message"
local s = score(msg)
userscores[user] = userscores[user] + s