mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-03-23 04:30:41 +01:00
Home fix
- Now using nether_players file
This commit is contained in:
parent
699d4f96c5
commit
cdd55a16f1
@ -75,9 +75,20 @@ minetest.register_chatcommand("sethome", {
|
|||||||
func = function(name)
|
func = function(name)
|
||||||
local player = minetest.env:get_player_by_name(name)
|
local player = minetest.env:get_player_by_name(name)
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
if not players_in_nether then return end
|
-- Find players in the nether
|
||||||
|
local players_in_nether = {}
|
||||||
|
local seeking = 0
|
||||||
|
|
||||||
|
local nether_file = io.open(minetest.get_worldpath().."/nether_players","r")
|
||||||
|
if not nether_file then return end
|
||||||
|
|
||||||
|
local player_in_nether_read = nether_file:read()
|
||||||
|
--if player_in_nether_read == "" then
|
||||||
|
--if not players_in_nether then return end
|
||||||
|
player_in_nether = player_in_nether_read:split(" ")
|
||||||
|
|
||||||
local is_in_nether = table.icontains(players_in_nether, name)
|
local is_in_nether = table.icontains(players_in_nether, name)
|
||||||
if is_in_nether then
|
if is_in_nether == true then
|
||||||
homepos.nether[player:get_player_name()] = pos
|
homepos.nether[player:get_player_name()] = pos
|
||||||
else
|
else
|
||||||
homepos.real[player:get_player_name()] = pos
|
homepos.real[player:get_player_name()] = pos
|
||||||
@ -85,11 +96,13 @@ minetest.register_chatcommand("sethome", {
|
|||||||
minetest.chat_send_player(name, "Home set!")
|
minetest.chat_send_player(name, "Home set!")
|
||||||
changed = true
|
changed = true
|
||||||
if changed then
|
if changed then
|
||||||
|
local output = 0
|
||||||
if is_in_nether then
|
if is_in_nether then
|
||||||
local output = io.open(nether_homes_file, "w")
|
output = io.open(nether_homes_file, "w")
|
||||||
else
|
else
|
||||||
local output = io.open(real_homes_file, "w")
|
output = io.open(real_homes_file, "w")
|
||||||
end
|
end
|
||||||
|
if output == 0 then return end -- Had not open the file
|
||||||
for i, v in pairs(homepos) do
|
for i, v in pairs(homepos) do
|
||||||
output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
|
output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user