Fix local echo in laggy servers
Instead of displaying the first buffer item, now display the whole buffer when required.
This commit is contained in:
parent
11f338ee01
commit
d2d65be1d9
9
init.lua
9
init.lua
|
@ -9,7 +9,7 @@ local channel = main_channel
|
||||||
local storage = minetest.get_mod_storage()
|
local storage = minetest.get_mod_storage()
|
||||||
local channels = {}
|
local channels = {}
|
||||||
local messages_sent = 0
|
local messages_sent = 0
|
||||||
local buffer = {}
|
local buffer = ''
|
||||||
local msgprefix
|
local msgprefix
|
||||||
local localplayer = '[you]'
|
local localplayer = '[you]'
|
||||||
local show_main_channel = true
|
local show_main_channel = true
|
||||||
|
@ -116,7 +116,8 @@ minetest.register_on_sending_chat_messages(function(msg)
|
||||||
end
|
end
|
||||||
local players = get_channel_users(c)
|
local players = get_channel_users(c)
|
||||||
if not players then return end
|
if not players then return end
|
||||||
table.insert(buffer, '-' .. c .. '- <' .. localplayer .. '> ' .. msg)
|
if #buffer > 0 then buffer = buffer .. '\n' end
|
||||||
|
buffer = buffer .. '-' .. c .. '- <' .. localplayer .. '> ' .. msg
|
||||||
messages_sent = messages_sent + #players
|
messages_sent = messages_sent + #players
|
||||||
for p = 1, #players do
|
for p = 1, #players do
|
||||||
minetest.run_server_chatcommand('msg', players[p] .. ' -' .. c ..
|
minetest.run_server_chatcommand('msg', players[p] .. ' -' .. c ..
|
||||||
|
@ -132,8 +133,8 @@ minetest.register_on_receiving_chat_messages(function(msg)
|
||||||
if messages_sent > 0 then
|
if messages_sent > 0 then
|
||||||
messages_sent = messages_sent - 1
|
messages_sent = messages_sent - 1
|
||||||
if messages_sent == 0 and #buffer > 0 then
|
if messages_sent == 0 and #buffer > 0 then
|
||||||
minetest.display_chat_message(buffer[1])
|
minetest.display_chat_message(buffer)
|
||||||
table.remove(buffer, 1)
|
buffer = ''
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue