Part teleport function as substantive func - as suggested by github user Reedych.

master
AndrejIT 2017-10-08 21:36:48 +03:00
parent 580a796a87
commit 1e07844d3f
1 changed files with 26 additions and 24 deletions

10
init.lua Normal file → Executable file
View File

@ -6,9 +6,7 @@ if minetest.setting_get_pos("static_spawnpoint") then
spawn_command.pos = minetest.setting_get_pos("static_spawnpoint")
end
minetest.register_chatcommand("spawn", {
description = "Teleport you to spawn point.",
func = function(name)
function teleport_to_spawn(name)
local player = minetest.get_player_by_name(name)
if player == nil then
-- just a check to prevent the server crashing
@ -31,5 +29,9 @@ minetest.register_chatcommand("spawn", {
player:setpos(spawn_command.pos)
minetest.chat_send_player(name, "Teleported to spawn!")
end
end,
end
minetest.register_chatcommand("spawn", {
description = "Teleport you to spawn point.",
func = teleport_to_spawn,
})