From 4dee25a43b1e0539f6175b407f9437c8cd091b7c Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 22 Jan 2019 18:59:16 +0530 Subject: [PATCH] Add lua mod --- chat_mod/init.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 chat_mod/init.lua diff --git a/chat_mod/init.lua b/chat_mod/init.lua new file mode 100644 index 0000000..ce8019f --- /dev/null +++ b/chat_mod/init.lua @@ -0,0 +1,17 @@ +function send_messages(res) + for message in string.gmatch(res["data"], "[^\n]+") do + minetest.chat_send_all(message) + end +end + +function main(http_api) + port = minetest.settings:get("chat_server_port") + if port == nil then + port = "9876" + end + http_api.fetch({url = "http://localhost:" .. port .. "/get"}, send_messages) + minetest.after(0.5, main, http_api) +end + +local http_api = minetest.request_http_api() +main(http_api)