Added /home, /sethome, and /setrespawn commands.
parent
1a1e2b6590
commit
f830b8dd80
|
@ -268,6 +268,67 @@ local function beds_list_fs(player, index, tab)
|
|||
return formspec
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("setspawn", {
|
||||
description = "Set your respawn location",
|
||||
params = "none",
|
||||
privs = "interact",
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "You must be in the game for this command to work."
|
||||
end
|
||||
local pos = player:get_pos()
|
||||
beds.spawn[name] = pos
|
||||
return true, "Your respawn position has been saved."
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("sethome", {
|
||||
description = "Set your home location",
|
||||
params = "none",
|
||||
privs = "interact",
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "You need to be in game for this command to work."
|
||||
end
|
||||
local wielded = player:get_wielded_item()
|
||||
if wielded:get_name() ~= "walkie:talkie" then
|
||||
return false, "You need to wield a walkie in your hand " ..
|
||||
"for this command to work."
|
||||
end
|
||||
local pos = player:get_pos()
|
||||
walkie.players[name].waypoints.saved = pos
|
||||
walkie.players[name].waypoints.pos = pos
|
||||
player:hud_change(walkie.meters[name].waypoint,
|
||||
"world_pos", pos)
|
||||
player:get_meta():set_string("waypoints",
|
||||
minetest.serialize(walkie.players[name].waypoints))
|
||||
return true, "Your home has been set to your current location."
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("home", {
|
||||
description = "Teleport to your home position",
|
||||
params = "none",
|
||||
privs = "interact",
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local wielded = player:get_wielded_item()
|
||||
if wielded:get_name() ~= "walkie:talkie" then
|
||||
return false, "You need to wield a walkie in your hand."
|
||||
end
|
||||
local pos = walkie.players[name].waypoints.saved
|
||||
if pos then
|
||||
player:set_pos(pos)
|
||||
return true, "You have warped to your home position."
|
||||
else
|
||||
return false, "You have yet to save a home location!"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local beds_list_index = {}
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "beds:inventory" then
|
||||
|
|
|
@ -26,7 +26,10 @@ end
|
|||
|
||||
local log1 = {["walkie"] = {
|
||||
["nowield"] = "You need to wield a Walkie Talkie in your hand to warp home!",
|
||||
["spawn"] = "You need to wield a Walkie Talkie in your hand to respawn!",
|
||||
["spawn"] = "You need to wield a Walkie Talkie in your hand to warp to your " ..
|
||||
"respawn position.\n\nWould you like to warp to the server spawn point?" ..
|
||||
"\n\nThis option can be set in the walkie." ..
|
||||
"",
|
||||
["home"] = "You don't have a home! To set your home, " ..
|
||||
"activate an Intercomm using your " ..
|
||||
"Walkie Talkie, or [Set Home] using a Bed." ..
|
||||
|
@ -85,7 +88,10 @@ jas0.message = message
|
|||
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "" then
|
||||
if formname == "jas0:respawn" and fields.ok then
|
||||
spawn.on_spawn(player)
|
||||
return
|
||||
elseif formname ~= "" then
|
||||
return false
|
||||
end
|
||||
local wielded = player:get_wielded_item():get_name()
|
||||
|
@ -103,8 +109,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
spawn.on_spawn(player)
|
||||
end
|
||||
else
|
||||
message(name, log1["walkie"]["spawn"], true)
|
||||
-- TODO Would you like to go to the server spawn?
|
||||
message(name, log1["walkie"]["spawn"], true, "jas0:respawn", "No Wielded Walkie", true)
|
||||
return false
|
||||
end
|
||||
elseif fields.home then
|
||||
|
|
Loading…
Reference in New Issue