Builtin: Backport MT5 client

master
MoNTE48 2020-02-04 17:37:08 +01:00
parent eac50692d7
commit 54f5679db3
4 changed files with 36 additions and 21 deletions

View File

@ -16,7 +16,7 @@ core.register_on_sending_chat_messages(function(message)
end
local cmd, param = string.match(message, "^%.([^ ]+) *(.*)")
param = param or ""
param = param or ""
if not cmd then
core.display_chat_message(core.gettext("-!- Empty command"))
@ -26,9 +26,9 @@ core.register_on_sending_chat_messages(function(message)
local cmd_def = core.registered_chatcommands[cmd]
if cmd_def then
core.set_last_run_mod(cmd_def.mod_origin)
local _, message = cmd_def.func(param)
if message then
core.display_chat_message(message)
local _, result = cmd_def.func(param)
if result then
core.display_chat_message(result)
end
else
core.display_chat_message(core.gettext("-!- Invalid command: ") .. cmd)
@ -40,8 +40,13 @@ end)
core.register_chatcommand("list_players", {
description = core.gettext("List online players"),
func = function()
local players = table.concat(core.get_player_names(), ", ")
core.display_chat_message(core.gettext("Online players: ") .. players)
local player_names = core.get_player_names()
if not player_names then
return false, core.gettext("This command is disabled by server.")
end
local players = table.concat(player_names, ", ")
return true, core.gettext("Online players: ") .. players
end
})

View File

@ -0,0 +1,16 @@
-- CSM death formspec. Only used when clientside modding is enabled, otherwise
-- handled by the engine.
core.register_on_death(function()
core.display_chat_message(fgettext("You died."))
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
"label[5,2;" .. fgettext("You died.") ..
"]button_exit[3.5,3;4,0.5;btn_respawn;".. fgettext("Respawn") .."]"
core.show_formspec("bultin:death", formspec)
end)
core.register_on_formspec_input(function(formname)
if formname == "bultin:death" then
core.send_respawn()
end
end)

View File

@ -1,5 +1,5 @@
-- Minetest: builtin/client/init.lua
local scriptpath = core.get_builtin_path()..DIR_DELIM
local scriptpath = core.get_builtin_path()
local clientpath = scriptpath.."client"..DIR_DELIM
local commonpath = scriptpath.."common"..DIR_DELIM
@ -8,16 +8,4 @@ dofile(commonpath .. "after.lua")
dofile(commonpath .. "chatcommands.lua")
dofile(clientpath .. "chatcommands.lua")
dofile(commonpath .. "vector.lua")
core.register_on_death(function()
core.display_chat_message(fgettext("You died."))
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
"label[5,2;" .. fgettext("You died.") .. "]button_exit[3.5,3;4,0.5;btn_respawn;".. fgettext("Respawn") .."]"
core.show_formspec("bultin:death", formspec)
end)
core.register_on_formspec_input(function(formname)
if formname == "bultin:death" then
core.send_respawn()
end
end)
dofile(clientpath .. "death_formspec.lua")

View File

@ -23,8 +23,14 @@ end
math.randomseed(os.time())
minetest = core
-- For compatibility with builtin from MT5
local get_builtin_path = core.get_builtin_path
function core.get_builtin_path()
return get_builtin_path() .. DIR_DELIM
end
-- Load other files
local scriptdir = core.get_builtin_path() .. DIR_DELIM
local scriptdir = core.get_builtin_path()
local gamepath = scriptdir .. "game" .. DIR_DELIM
local clientpath = scriptdir .. "client" .. DIR_DELIM
local commonpath = scriptdir .. "common" .. DIR_DELIM