Skip to content

Commit

Permalink
chat
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 12, 2022
1 parent 219b371 commit ba3ae44
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
globals = {
"mtui"
"mtui",
"minetest"
}

read_globals = {
Expand All @@ -8,7 +9,6 @@ read_globals = {
table = {fields = {"copy", "getn"}},

-- Minetest
"minetest",
"vector", "ItemStack",
"dump", "dump2",
"VoxelArea"
Expand Down
31 changes: 31 additions & 0 deletions handlers/chat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


local old_chat_send_all = minetest.chat_send_all
local old_chat_send_player = minetest.chat_send_player

-- message/PM from the ui to ingame
mtui.register_on_command("send_chat_message", function(data)
old_chat_send_player(data.name, "DM from " .. data.name .. ": " .. data.text)
end)

-- intercept ingame message and send themto the ui
function minetest.chat_send_player(name, text)
old_chat_send_player(name, text)
mtui.send_command({
type = "chat_send_player",
data = {
name = name,
text = text
}
})
end

function minetest.chat_send_all(text)
old_chat_send_all(text)
mtui.send_command({
type = "chat_send_all",
data = {
text = text
}
})
end
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ loadfile(MP.."/bridge_tx.lua")(http)
dofile(MP.."/tan.lua")
dofile(MP.."/stats.lua")
dofile(MP.."/handlers/ping.lua")
dofile(MP.."/handlers/chat.lua")
dofile(MP.."/handlers/execute_command.lua")

0 comments on commit ba3ae44

Please sign in to comment.