From cdd55a16f197d2716f0711d1f3e86cd28c105469 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Sat, 1 Nov 2014 14:01:46 +0100 Subject: [PATCH] Home fix - Now using nether_players file --- minetestforfun_game/mods/sethome/init.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/minetestforfun_game/mods/sethome/init.lua b/minetestforfun_game/mods/sethome/init.lua index 12a2b8de..1d369ae7 100755 --- a/minetestforfun_game/mods/sethome/init.lua +++ b/minetestforfun_game/mods/sethome/init.lua @@ -75,9 +75,20 @@ minetest.register_chatcommand("sethome", { func = function(name) local player = minetest.env:get_player_by_name(name) 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) - if is_in_nether then + if is_in_nether == true then homepos.nether[player:get_player_name()] = pos else homepos.real[player:get_player_name()] = pos @@ -85,11 +96,13 @@ minetest.register_chatcommand("sethome", { minetest.chat_send_player(name, "Home set!") changed = true if changed then + local output = 0 if is_in_nether then - local output = io.open(nether_homes_file, "w") + output = io.open(nether_homes_file, "w") else - local output = io.open(real_homes_file, "w") + output = io.open(real_homes_file, "w") end + if output == 0 then return end -- Had not open the file for i, v in pairs(homepos) do output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n") end