mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-03-31 17:50:41 +02:00
[conf & h2omes & nether] Add nether static spawnpoint
This commit is contained in:
parent
b1adb55c11
commit
76bc4b0330
@ -78,6 +78,8 @@ movement_gravity = 9.5
|
|||||||
movement_speed_jump = 6.5
|
movement_speed_jump = 6.5
|
||||||
# Emplacement du static spawn point
|
# Emplacement du static spawn point
|
||||||
static_spawnpoint = 24,97,-1
|
static_spawnpoint = 24,97,-1
|
||||||
|
# Emplacment du static spawn pour le nether
|
||||||
|
nether_static_spawnpoint = 43, -20020, -12
|
||||||
# Désactivation de l'anti-cheat qui fait ce téléporter en arrière si l'on va trop vite
|
# Désactivation de l'anti-cheat qui fait ce téléporter en arrière si l'on va trop vite
|
||||||
disable_anticheat = true
|
disable_anticheat = true
|
||||||
|
|
||||||
|
@ -355,7 +355,17 @@ minetest.register_privilege("home", "Can use /sethome, /home, /setpit and /pit")
|
|||||||
minetest.register_chatcommand("spawn", {
|
minetest.register_chatcommand("spawn", {
|
||||||
description = "Teleport a player to the defined spawnpoint",
|
description = "Teleport a player to the defined spawnpoint",
|
||||||
func = function(name)
|
func = function(name)
|
||||||
local to_pos = minetest.setting_get_pos("static_spawnpoint")
|
local to_pos
|
||||||
|
|
||||||
|
if minetest.get_modpath("nether") ~= nil and table.icontains(nether.players_in_nether, name) then
|
||||||
|
if nether.spawn_point then
|
||||||
|
to_pos = nether.spawn_point
|
||||||
|
end
|
||||||
|
-- Otherwise error about no spawn
|
||||||
|
else
|
||||||
|
to_pos = minetest.setting_get_pos("static_spawnpoint")
|
||||||
|
end
|
||||||
|
|
||||||
if not to_pos then
|
if not to_pos then
|
||||||
minetest.chat_send_player(name, "ERROR: No spawn point is set on this server!")
|
minetest.chat_send_player(name, "ERROR: No spawn point is set on this server!")
|
||||||
return false
|
return false
|
||||||
|
@ -11,6 +11,9 @@ minetest.after(5, function()
|
|||||||
abm_allowed = true
|
abm_allowed = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
nether.spawn_point = minetest.string_to_pos(minetest.setting_get("nether_static_spawnpoint") or "")
|
||||||
|
-- If nil then we use random spawn points
|
||||||
|
|
||||||
table.icontains = table.icontains or function(t, v)
|
table.icontains = table.icontains or function(t, v)
|
||||||
for _,i in ipairs(t) do
|
for _,i in ipairs(t) do
|
||||||
if i == v then
|
if i == v then
|
||||||
@ -20,7 +23,7 @@ table.icontains = table.icontains or function(t, v)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local players_in_nether = {}
|
nether.players_in_nether = {}
|
||||||
-- only get info from file if nether prisons
|
-- only get info from file if nether prisons
|
||||||
if nether_prisons then
|
if nether_prisons then
|
||||||
local file = io.open(minetest.get_worldpath()..'/nether_players', "r")
|
local file = io.open(minetest.get_worldpath()..'/nether_players', "r")
|
||||||
@ -28,14 +31,14 @@ if nether_prisons then
|
|||||||
local contents = file:read('*all')
|
local contents = file:read('*all')
|
||||||
io.close(file)
|
io.close(file)
|
||||||
if contents then
|
if contents then
|
||||||
players_in_nether = string.split(contents, " ")
|
nether.players_in_nether = string.split(contents, " ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function save_nether_players()
|
local function save_nether_players()
|
||||||
local output = ''
|
local output = ''
|
||||||
for _,name in ipairs(players_in_nether) do
|
for _,name in ipairs(nether.players_in_nether) do
|
||||||
output = output..name..' '
|
output = output..name..' '
|
||||||
end
|
end
|
||||||
local f = io.open(minetest.get_worldpath()..'/nether_players', "w")
|
local f = io.open(minetest.get_worldpath()..'/nether_players', "w")
|
||||||
@ -77,6 +80,7 @@ local function get_player_died_target(player)
|
|||||||
target.y = portal_target + math.random(4)
|
target.y = portal_target + math.random(4)
|
||||||
return target
|
return target
|
||||||
end
|
end
|
||||||
|
nether.get_player_died_target = get_player_died_target
|
||||||
|
|
||||||
-- used for obsidian portal
|
-- used for obsidian portal
|
||||||
local function obsidian_teleport(player, pname)
|
local function obsidian_teleport(player, pname)
|
||||||
@ -86,11 +90,12 @@ local function obsidian_teleport(player, pname)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if not mclike_portal then
|
if not mclike_portal then
|
||||||
|
-- Pick random for obsidian, poor people gotta suffer
|
||||||
local target = vector.round(get_player_died_target(player))
|
local target = vector.round(get_player_died_target(player))
|
||||||
if generated_or_generate(target) then
|
if generated_or_generate(target) then
|
||||||
player:moveto(target)
|
player:moveto(target)
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -98,16 +103,20 @@ end
|
|||||||
-- teleports players to nether or helps it
|
-- teleports players to nether or helps it
|
||||||
function nether.player_to_nether(player, safe)
|
function nether.player_to_nether(player, safe)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
if table.icontains(players_in_nether, pname) then
|
if table.icontains(nether.players_in_nether, pname) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
players_in_nether[#players_in_nether+1] = pname
|
nether.players_in_nether[#nether.players_in_nether+1] = pname
|
||||||
save_nether_players()
|
save_nether_players()
|
||||||
if not safe then
|
if not safe then
|
||||||
minetest.chat_send_player(pname, "For any reason you arrived here. Type /nether_help to find out things like craft recipes.")
|
minetest.chat_send_player(pname, "For any reason you arrived here. Type /nether_help to find out things like craft recipes.")
|
||||||
player:set_hp(0)
|
player:set_hp(0)
|
||||||
if not nether_prisons then
|
if not nether_prisons then
|
||||||
player:moveto(get_player_died_target(player))
|
if nether.spawn_point then
|
||||||
|
player:moveto(nether.spawn_point)
|
||||||
|
else
|
||||||
|
player:moveto(get_player_died_target(player))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
update_background(player, true)
|
update_background(player, true)
|
||||||
@ -116,9 +125,9 @@ end
|
|||||||
function nether.player_from_nether(player)
|
function nether.player_from_nether(player)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local changes
|
local changes
|
||||||
for n,i in ipairs(players_in_nether) do
|
for n,i in ipairs(nether.players_in_nether) do
|
||||||
if i == pname then
|
if i == pname then
|
||||||
table.remove(players_in_nether, n)
|
table.remove(nether.players_in_nether, n)
|
||||||
changes = true
|
changes = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -193,10 +202,15 @@ if nether_prisons then
|
|||||||
-- randomly set player position when he/she dies in nether
|
-- randomly set player position when he/she dies in nether
|
||||||
minetest.register_on_respawnplayer(function(player)
|
minetest.register_on_respawnplayer(function(player)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
if not table.icontains(players_in_nether, pname) then
|
if not table.icontains(nether.players_in_nether, pname) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local target = get_player_died_target(player)
|
local target
|
||||||
|
if nether.spawn_point then
|
||||||
|
target = nether.spawn_point
|
||||||
|
else
|
||||||
|
target = get_player_died_target(player)
|
||||||
|
end
|
||||||
player:moveto(target)
|
player:moveto(target)
|
||||||
minetest.after(0, function(pname, target)
|
minetest.after(0, function(pname, target)
|
||||||
-- fixes respawn bug
|
-- fixes respawn bug
|
||||||
@ -213,7 +227,7 @@ if nether_prisons then
|
|||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local ppos = player:getpos()
|
local ppos = player:getpos()
|
||||||
if table.icontains(players_in_nether, pname) then
|
if table.icontains(nether.players_in_nether, pname) then
|
||||||
if ppos.y > nether.start then
|
if ppos.y > nether.start then
|
||||||
player:moveto({x=ppos.x, y=portal_target, z=ppos.z})
|
player:moveto({x=ppos.x, y=portal_target, z=ppos.z})
|
||||||
update_background(player, true)
|
update_background(player, true)
|
||||||
@ -241,7 +255,7 @@ if nether_prisons then
|
|||||||
-- set background when player joins
|
-- set background when player joins
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
minetest.after(0, function(player)
|
minetest.after(0, function(player)
|
||||||
if player and player:getpos() and player:getpos().y < nether.start then
|
if player:getpos().y < nether.start then
|
||||||
update_background(player, true)
|
update_background(player, true)
|
||||||
end
|
end
|
||||||
end, player)
|
end, player)
|
||||||
@ -250,15 +264,16 @@ else
|
|||||||
-- test if player is in nether when he/she joins
|
-- test if player is in nether when he/she joins
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
minetest.after(0, function(player)
|
minetest.after(0, function(player)
|
||||||
|
local pname = player:get_player_name()
|
||||||
if player:getpos().y < nether.start then
|
if player:getpos().y < nether.start then
|
||||||
if not table.icontains(players_in_nether, pname) then
|
if not table.icontains(nether.players_in_nether, pname) then
|
||||||
players_in_nether[#players_in_nether+1] = pname
|
nether.players_in_nether[#nether.players_in_nether+1] = pname
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for i,name in pairs(players_in_nether) do
|
for i,name in pairs(nether.players_in_nether) do
|
||||||
if name == pname then
|
if name == pname then
|
||||||
players_in_nether[i] = nil
|
nether.players_in_nether[i] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -298,7 +313,7 @@ local particledef = {
|
|||||||
-- teleports player to neter (obsidian portal)
|
-- teleports player to neter (obsidian portal)
|
||||||
local function obsi_teleport_player(player, pos, target)
|
local function obsi_teleport_player(player, pos, target)
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
if table.icontains(players_in_nether, pname) then
|
if table.icontains(nether.players_in_nether, pname) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -313,7 +328,7 @@ local function obsi_teleport_player(player, pos, target)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
players_in_nether[#players_in_nether+1] = pname
|
nether.players_in_nether[#nether.players_in_nether+1] = pname
|
||||||
save_nether_players()
|
save_nether_players()
|
||||||
update_background(player, true)
|
update_background(player, true)
|
||||||
|
|
||||||
@ -671,6 +686,8 @@ function nether_port(player, pos)
|
|||||||
pos.y = y
|
pos.y = y
|
||||||
end
|
end
|
||||||
player:moveto(pos)
|
player:moveto(pos)
|
||||||
|
elseif nether.spawn_point then
|
||||||
|
player:moveto(nether.spawn_point)
|
||||||
else
|
else
|
||||||
set_portal(known_portals_u, pos.z,pos.x, pos.y)
|
set_portal(known_portals_u, pos.z,pos.x, pos.y)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user