localize a few variables, stricter luacheckrc

master
BuckarooBanzay 2021-01-03 17:11:27 +01:00
parent d6dd750dfd
commit d61f09b135
6 changed files with 12 additions and 8 deletions

View File

@ -1,4 +1,3 @@
allow_defined_top = true
globals = {
"beerchat"

View File

@ -1,9 +1,9 @@
function format_string(s, tab)
local function format_string(s, tab)
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
end
function colorize_target_name(s, target)
local function colorize_target_name(s, target)
if not target or not s then
return s
end

View File

@ -1,7 +1,7 @@
-- # chat a.k.a. hash chat/ channel chat code, to send messages in chat channels using #
-- e.g. #my channel: hello everyone in my channel!
hashchat_lastrecv = {}
local hashchat_lastrecv = {}
minetest.register_on_chat_message(function(name, message)
local msg_data = {name=name,message=message}

9
pm.lua
View File

@ -6,7 +6,14 @@ local private_message_sound = "beerchat_chime" -- Sound when you receive a priv
local self_message_sound = "beerchat_utter" -- Sound when you send a private message to yourself
-- @ chat a.k.a. at chat/ PM chat code, to PM players using @player1 only you can read this player1!!
atchat_lastrecv = {}
local atchat_lastrecv = {}
-- cleanup upon leave
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
atchat_lastrecv[name] = nil
end)
minetest.register_on_chat_message(function(name, message)
minetest.log("action", "CHAT " .. name .. ": " .. message)

View File

@ -26,7 +26,5 @@ end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
beerchat.playersChannels[name] = nil
atchat_lastrecv[name] = nil
beerchat.currentPlayerChannel[name] = nil
end)

View File

@ -2,7 +2,7 @@
local http = beerchat.http
local recv_loop
function handle_data(data)
local function handle_data(data)
if not data or not data.username or not data.message or not data.name then
return
end