From 8b6847f2ab8c7deaa32220fd382811c707c1aed4 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Sun, 11 Jun 2023 03:25:45 -0400 Subject: [PATCH] sethome removed, in subnasa we must have a bed to stay safe place --- mods/sethome/README.txt | 7 --- mods/sethome/init.lua | 97 ---------------------------------------- mods/sethome/license.txt | 24 ---------- 3 files changed, 128 deletions(-) delete mode 100644 mods/sethome/README.txt delete mode 100644 mods/sethome/init.lua delete mode 100644 mods/sethome/license.txt diff --git a/mods/sethome/README.txt b/mods/sethome/README.txt deleted file mode 100644 index 6f0a282..0000000 --- a/mods/sethome/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -Minetest Game mod: sethome -========================== -See license.txt for license information. - -Authors of source code ----------------------- -sfan5 (MIT) diff --git a/mods/sethome/init.lua b/mods/sethome/init.lua deleted file mode 100644 index 13a33e5..0000000 --- a/mods/sethome/init.lua +++ /dev/null @@ -1,97 +0,0 @@ - -sethome = {} - -local homes_file = minetest.get_worldpath() .. "/homes" -local homepos = {} - -local function loadhomes() - local input = io.open(homes_file, "r") - if not input then - return -- no longer an error - end - - -- Iterate over all stored positions in the format "x y z player" for each line - for pos, name in input:read("*a"):gmatch("(%S+ %S+ %S+)%s([%w_-]+)[\r\n]") do - homepos[name] = minetest.string_to_pos(pos) - end - input:close() -end - -loadhomes() - -sethome.set = function(name, pos) - local player = minetest.get_player_by_name(name) - if not player or not pos then - return false - end - player:set_attribute("sethome:home", minetest.pos_to_string(pos)) - - -- remove `name` from the old storage file - local data = {} - local output = io.open(homes_file, "w") - if output then - homepos[name] = nil - for i, v in pairs(homepos) do - table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, i)) - end - output:write(table.concat(data)) - io.close(output) - return true - end - return true -- if the file doesn't exist - don't return an error. -end - -sethome.get = function(name) - local player = minetest.get_player_by_name(name) - local pos = minetest.string_to_pos(player:get_attribute("sethome:home")) - if pos then - return pos - end - - -- fetch old entry from storage table - pos = homepos[name] - if pos then - return vector.new(pos) - else - return nil - end -end - -sethome.go = function(name) - local pos = sethome.get(name) - local player = minetest.get_player_by_name(name) - if player and pos then - player:setpos(pos) - return true - end - return false -end - -minetest.register_privilege("home", { - description = "Can use /sethome and /home", - give_to_singleplayer = false -}) - -minetest.register_chatcommand("home", { - description = "Teleport you to your home point", - privs = {home = true}, - func = function(name) - if sethome.go(name) then - return true, "Teleported to home!" - end - return false, "Set a home using /sethome" - end, -}) - -minetest.register_chatcommand("sethome", { - description = "Set your home point", - privs = {home = true}, - func = function(name) - name = name or "" -- fallback to blank name if nil - local player = minetest.get_player_by_name(name) - if player and sethome.set(name, player:getpos()) then - return true, "Home set!" - end - return false, "Player not found!" - end, -}) diff --git a/mods/sethome/license.txt b/mods/sethome/license.txt deleted file mode 100644 index 09f03b0..0000000 --- a/mods/sethome/license.txt +++ /dev/null @@ -1,24 +0,0 @@ -License of source code ----------------------- - -The MIT License (MIT) -Copyright (C) 2014-2016 sfan5 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or -substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -For more details: -https://opensource.org/licenses/MIT