Add death messages
This commit is contained in:
parent
a9ed7aa159
commit
c4afd9139e
|
@ -1,21 +1,29 @@
|
||||||
|
local http_api = minetest.request_http_api()
|
||||||
|
|
||||||
function send_messages(res)
|
function send_messages(res)
|
||||||
for message in string.gmatch(res["data"], "[^\n]+") do
|
for message in string.gmatch(res["data"], "[^\n]+") do
|
||||||
minetest.chat_send_all(message)
|
minetest.chat_send_all(message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function main(http_api)
|
function main()
|
||||||
port = minetest.settings:get("chat_server_port")
|
port = minetest.settings:get("chat_server_port")
|
||||||
if port == nil then
|
if port == nil then
|
||||||
port = "9876"
|
port = "9876"
|
||||||
end
|
end
|
||||||
http_api.fetch({url = "http://localhost:" .. port .. "/get"}, send_messages)
|
http_api.fetch({url = "http://localhost:" .. port .. "/get"}, send_messages)
|
||||||
minetest.after(0.5, main, http_api)
|
minetest.after(0.5, main)
|
||||||
|
end
|
||||||
|
|
||||||
|
function dead(player)
|
||||||
|
http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode",
|
||||||
|
post_data = {message = player.get_player_name(player) ..
|
||||||
|
" died."}})
|
||||||
end
|
end
|
||||||
|
|
||||||
local http_api = minetest.request_http_api()
|
|
||||||
if http_api == nil then
|
if http_api == nil then
|
||||||
minetest.log("error", "Chat Mod is not in secure.http_mods or secure.trusted_mods. Exiting.")
|
minetest.log("error", "Chat Mod is not in secure.http_mods or secure.trusted_mods. Exiting.")
|
||||||
else
|
else
|
||||||
main(http_api)
|
main()
|
||||||
end
|
end
|
||||||
|
minetest.register_on_dieplayer(dead)
|
||||||
|
|
Loading…
Reference in New Issue