Update builtin
This commit is contained in:
parent
9a65213458
commit
a51369d706
|
@ -82,7 +82,7 @@ core.register_chatcommand("me", {
|
|||
core.register_chatcommand("admin", {
|
||||
description = "Show the name of the server owner",
|
||||
func = function(name)
|
||||
local admin = minetest.settings:get("name")
|
||||
local admin = core.settings:get("name")
|
||||
if admin then
|
||||
return true, "The administrator of this server is "..admin.."."
|
||||
else
|
||||
|
@ -104,7 +104,7 @@ core.register_chatcommand("privs", {
|
|||
})
|
||||
|
||||
local function handle_grant_command(caller, grantname, grantprivstr)
|
||||
local caller_privs = minetest.get_player_privs(caller)
|
||||
local caller_privs = core.get_player_privs(caller)
|
||||
if not (caller_privs.privs or caller_privs.basic_privs) then
|
||||
return false, "Your privileges are insufficient."
|
||||
end
|
||||
|
@ -969,43 +969,47 @@ core.register_chatcommand("clearinv", {
|
|||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("killme", {
|
||||
description = "Kill yourself to respawn",
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
player:set_hp(0)
|
||||
return true
|
||||
local function handle_kill_command(killer, victim)
|
||||
if core.settings:get_bool("enable_damage") == false then
|
||||
return false, "Players can't be killed, damage has been disabled."
|
||||
end
|
||||
local victimref = core.get_player_by_name(victim)
|
||||
if victimref == nil then
|
||||
return false, string.format("Player %s is not online.", victim)
|
||||
elseif victimref:get_hp() <= 0 then
|
||||
if killer == victim then
|
||||
return false, "You are already dead."
|
||||
else
|
||||
for _, callback in pairs(core.registered_on_respawnplayers) do
|
||||
if callback(player) then
|
||||
return true
|
||||
return false, string.format("%s is already dead.", victim)
|
||||
end
|
||||
end
|
||||
if not killer == victim then
|
||||
core.log("action", string.format("%s killed %s", killer, victim))
|
||||
end
|
||||
-- Kill victim
|
||||
victimref:set_hp(0)
|
||||
return true, string.format("%s has been killed.", victim)
|
||||
end
|
||||
|
||||
-- There doesn't seem to be a way to get a default spawn pos from the lua API
|
||||
return false, "No static_spawnpoint defined"
|
||||
end
|
||||
else
|
||||
-- Show error message if used when not logged in, eg: from IRC mod
|
||||
return false, "You need to be online to be killed!"
|
||||
end
|
||||
end
|
||||
core.register_chatcommand("kill", {
|
||||
params = "[<name>]",
|
||||
description = "Kill player or yourself",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
return handle_kill_command(name, param == "" and name or param)
|
||||
end,
|
||||
})
|
||||
|
||||
local spawn_spawnpos = minetest.setting_get_pos("static_spawnpoint")
|
||||
|
||||
minetest.register_chatcommand("spawn", {
|
||||
core.register_chatcommand("spawn", {
|
||||
params = "",
|
||||
description = "Teleport to the spawn point",
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local player = core.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "Player not found"
|
||||
return false, "Command called by invalid player"
|
||||
end
|
||||
if spawn_spawnpos then
|
||||
player:set_pos(spawn_spawnpos)
|
||||
if core.setting_get_pos("static_spawnpoint") then
|
||||
player:set_pos(core.setting_get_pos("static_spawnpoint"))
|
||||
return true, "Teleporting to spawn..."
|
||||
else
|
||||
return false, "The spawn point is not set!"
|
||||
|
@ -1013,24 +1017,22 @@ minetest.register_chatcommand("spawn", {
|
|||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("setspawn", {
|
||||
core.register_chatcommand("setspawn", {
|
||||
params = "",
|
||||
description = "Sets the spawn point to your current position",
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local player = core.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "Player not found"
|
||||
return false, "Command called by invalid player"
|
||||
end
|
||||
local pos = player:get_pos()
|
||||
local x = math.floor(pos.x)
|
||||
local y = math.floor(pos.y)
|
||||
local z = math.floor(pos.z)
|
||||
local pos_string = x..","..y..","..z
|
||||
local pos_string_2 = "Setting spawn point to ("..x..", "..y..", "..z..")"
|
||||
minetest.setting_set("static_spawnpoint", pos_string)
|
||||
spawn_spawnpos = pos
|
||||
minetest.setting_save()
|
||||
return true, pos_string_2
|
||||
local pos = vector.round(player:get_pos())
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
local pos_to_string = x..","..y..","..z
|
||||
core.setting_set("static_spawnpoint", pos_to_string)
|
||||
core.setting_save()
|
||||
return true, "Setting spawn point to ("..x..", "..y..", "..z..")"
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -24,7 +24,7 @@ local sb_bg = {} -- statbar background ids
|
|||
local items = {}
|
||||
|
||||
local function throw_error(msg)
|
||||
minetest.log("error", "HUD[error]: " .. msg)
|
||||
core.log("error", "HUD[error]: " .. msg)
|
||||
end
|
||||
|
||||
--
|
||||
|
@ -156,7 +156,7 @@ local function add_hud_item(player, name, def)
|
|||
hud_id[i_name].id = player:hud_add(def)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
core.register_on_joinplayer(function(player)
|
||||
-- add the backgrounds for statbars
|
||||
for _,item in pairs(sb_bg) do
|
||||
add_hud_item(player, _.."_bg", item)
|
||||
|
|
|
@ -579,9 +579,9 @@ function core.item_eat(hp_change, replace_with_item)
|
|||
local pos = user:get_pos()
|
||||
pos.y = pos.y + 1.5
|
||||
local itemname = itemstack:get_name()
|
||||
local texture = minetest.registered_items[itemname].inventory_image
|
||||
minetest.sound_play("player_eat", {pos = pos, max_hear_distance = 10, gain = 0.3})
|
||||
minetest.add_particlespawner({
|
||||
local texture = core.registered_items[itemname].inventory_image
|
||||
core.sound_play("player_eat", {pos = pos, max_hear_distance = 10, gain = 0.3})
|
||||
core.add_particlespawner({
|
||||
amount = 20,
|
||||
time = 0.1,
|
||||
minpos = {x = pos.x, y = pos.y, z = pos.z},
|
||||
|
|
|
@ -228,14 +228,14 @@ core.register_entity(":__builtin:item", {
|
|||
end
|
||||
end
|
||||
|
||||
local node = minetest.get_node_or_nil(self.object:get_pos())
|
||||
local node = core.get_node_or_nil(self.object:get_pos())
|
||||
if not node then
|
||||
return
|
||||
end
|
||||
if minetest.get_item_group(node.name, "lava") > 0 then
|
||||
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 10})
|
||||
if core.get_item_group(node.name, "lava") > 0 then
|
||||
core.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 10})
|
||||
self.object:remove()
|
||||
minetest.add_particlespawner({
|
||||
core.add_particlespawner({
|
||||
amount = 3,
|
||||
time = 0.1,
|
||||
minpos = {x = pos.x - 0.1, y = pos.y + 0.1, z = pos.z - 0.1 },
|
||||
|
|
|
@ -44,7 +44,7 @@ local player_list = {}
|
|||
core.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
player_list[player_name] = player
|
||||
if not minetest.is_singleplayer() then
|
||||
if not core.is_singleplayer() then
|
||||
core.chat_send_all("=> " .. player_name .. " has joined the server")
|
||||
end
|
||||
end)
|
||||
|
@ -79,8 +79,8 @@ function core.is_player(player)
|
|||
end
|
||||
|
||||
|
||||
function minetest.player_exists(name)
|
||||
return minetest.get_auth_handler().get_auth(name) ~= nil
|
||||
function core.player_exists(name)
|
||||
return core.get_auth_handler().get_auth(name) ~= nil
|
||||
end
|
||||
|
||||
-- Returns two position vectors representing a box of `radius` in each
|
||||
|
@ -181,7 +181,7 @@ function core.intersects_protection(minp, maxp, player_name, interval)
|
|||
elseif maxp[c] == minp[c] then
|
||||
d[c] = 1 -- Any value larger than 0 to avoid division by zero
|
||||
else -- maxp[c] < minp[c], print error and treat as protection intersected
|
||||
minetest.log("error", "maxp < minp in 'minetest.intersects_protection()'")
|
||||
core.log("error", "maxp < minp in 'minetest.intersects_protection()'")
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -234,7 +234,7 @@ function core.http_add_fetch(httpenv)
|
|||
end
|
||||
|
||||
function core.close_formspec(player_name, formname)
|
||||
return minetest.show_formspec(player_name, formname, "")
|
||||
return core.show_formspec(player_name, formname, "")
|
||||
end
|
||||
|
||||
function core.cancel_shutdown_requests()
|
||||
|
|
Loading…
Reference in New Issue