From d3ac2e64b14dacd538553865f8922d1f79aee911 Mon Sep 17 00:00:00 2001 From: Wouters Dorian Date: Fri, 31 Jul 2015 16:22:58 +0200 Subject: [PATCH] Remove [forceload] --- mods/forceload/README.md | 9 -- mods/forceload/init.lua | 154 ------------------- mods/forceload/textures/forceload_anchor.png | Bin 406 -> 0 bytes 3 files changed, 163 deletions(-) delete mode 100755 mods/forceload/README.md delete mode 100755 mods/forceload/init.lua delete mode 100755 mods/forceload/textures/forceload_anchor.png diff --git a/mods/forceload/README.md b/mods/forceload/README.md deleted file mode 100755 index f9c5c1bb..00000000 --- a/mods/forceload/README.md +++ /dev/null @@ -1,9 +0,0 @@ -Forceload Mod -============= - -This mod allows areas in the map to be keep loaded. -Use the forceload:anchor block. - -Created by rubenwardy - -License: LGPL 2.1 or later diff --git a/mods/forceload/init.lua b/mods/forceload/init.lua deleted file mode 100755 index 55c2928e..00000000 --- a/mods/forceload/init.lua +++ /dev/null @@ -1,154 +0,0 @@ -local _pts = minetest.pos_to_string -function minetest.pos_to_string(pos) - if not pos then - return "(-,-,-)" - end - return _pts(pos) -end - -local elapsed_time = 0 - --- Makes sure that force load areas are handled correctly -function ForceloadManager(filetoopen, hide_file_errors) - local blocks = {} - if filetoopen ~= nil then - local file = io.open(filetoopen, "r") - if file then - local table = minetest.deserialize(file:read("*all")) - file:close() - if type(table) == "table" then - blocks = table - end - elseif not hide_file_errors then - minetest.log("error", "File "..filetoopen.." does not exist!") - end - end - for i = 1, #blocks do - if not minetest.forceload_block(blocks[i]) then - minetest.log("error", "Failed to load block " .. minetest.pos_to_string(blocks[i])) - end - end - return { - _blocks = blocks, - load = function(self, pos) - if minetest.forceload_block(pos) then - table.insert(self._blocks, vector.new(pos)) - return true - end - minetest.log("error", "Failed to load block " .. minetest.pos_to_string(pos)) - return false - end, - unload = function(self, pos) - for i = 1, #self._blocks do - if vector.equals(pos, self._blocks[i]) then - minetest.forceload_free_block(pos) - table.remove(self._blocks, i) - return true - end - end - return false - end, - save = function(self, filename) - local file = io.open(filename, "w") - if file then - file:write(minetest.serialize(self._blocks)) - file:close() - end - end, - verify = function(self) - return self:verify_each(function(pos, block) - local name = "ignore" - if block ~= nil then - name = block.name - end - - if name == "ignore" then - if not pos.last or elapsed_time > pos.last + 15 then - pos.last = elapsed_time - if not minetest.forceload_block(pos) then - minetest.log("error", "Failed to force load " .. minetest.pos_to_string(pos)) - pos.remove = true - end - end - return false - elseif name == "forceload:anchor" then - pos.last = elapsed_time - return true - else - minetest.log("error", minetest.pos_to_string(pos) .. " shouldn't be loaded") - pos.remove = true - return false - end - end) - end, - verify_each = function(self, func) - local not_loaded = {} - for i = 1, #self._blocks do - local res = minetest.get_node(self._blocks[i]) - if not func(self._blocks[i], res) then - --[[table.insert(not_loaded, { - pos = self._blocks[i], - i = i, - b = res })]]-- - end - end - return not_loaded - end, - clean = function(self) - local i = 1 - while i <= #self._blocks do - if self._blocks[i].remove then - minetest.forceload_free_block(self._blocks[i]) - table.remove(self._blocks, i) - else - i = i + 1 - end - end - end - } -end - -local flm = ForceloadManager(minetest.get_worldpath().."/flm.json", true) - -minetest.register_privilege("forceload", "Allows players to use forceload block anchors") - -minetest.register_node("forceload:anchor",{ - description = "Block Anchor", - walkable = false, - tiles = {"forceload_anchor.png"}, - groups = {cracky = 3, oddly_breakable_by_hand = 2}, - after_destruct = function(pos) - flm:unload(pos) - flm:save(minetest.get_worldpath().."/flm.json") - end, - after_place_node = function(pos, placer) - if not minetest.check_player_privs(placer:get_player_name(), - {forceload = true}) then - minetest.chat_send_player(placer:get_player_name(), "The forceload privilege is required to do that.") - elseif flm:load(pos) then - flm:save(minetest.get_worldpath().."/flm.json") - return - end - minetest.set_node(pos, {name="air"}) - return true - end -}) - -minetest.register_craft({ - output = "forceload:anchor", - recipe = { - {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"}, - {"default:mese_crystal", "wool:blue", "default:mese_crystal"}, - {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"} - } -}) - -local function tick() - minetest.after(5, tick) - --print("Verifying...") - flm:verify() - flm:clean() -end - -tick() - diff --git a/mods/forceload/textures/forceload_anchor.png b/mods/forceload/textures/forceload_anchor.png deleted file mode 100755 index 532c1c7d406e5b1601bc8880dbc78ce77a2ab984..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 406 zcmV;H0crk;P)Rs06KpFJAeQ@fdD;&06&EQK!yN8 zhX6r{078iXLy7=IivUE707Z=eMveeSj{r!J07#JlNs<6clK@MU085nsOqKvmmjF$e z08W?yPniHxo&Zyy092p=R-yn_qX1W=09d5}S*8G4rvO^009&a8l0C%$006#8L_t&- z87;w!QiCuM1<>oLWd@@8AZBcZ+ z8Yf@OwPG$DmSr5*;)9eFKsv;RCMI?A&oA-v1KT_nYpK@rKmY&$07*qoM6N<$g6w0D A<^TWy