├── .github └── workflows │ └── build.yml ├── .luacheckrc ├── LICENSE ├── README.md ├── init.lua ├── mod.conf └── settingtypes.txt /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: apt 13 | run: sudo apt-get install -y luarocks 14 | - name: luacheck install 15 | run: luarocks install --local luacheck 16 | - name: luacheck run 17 | run: $HOME/.luarocks/bin/luacheck ./ 18 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | unused_args = false 2 | allow_defined_top = true 3 | exclude_files = {".luacheckrc"} 4 | 5 | globals = { 6 | "minetest", 7 | } 8 | 9 | read_globals = { 10 | string = {fields = {"split"}}, 11 | table = {fields = {"copy", "getn"}}, 12 | 13 | -- Builtin 14 | "vector", "ItemStack", 15 | "dump", "DIR_DELIM", "VoxelArea", "Settings", 16 | 17 | -- MTG 18 | "default", "sfinv", "creative", "carts", 19 | 20 | --depends 21 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | See http://www.gnu.org/licenses/gpl-3.0.en.html 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mapfix 2 | 3 | Fix some map errors (flow and light problems) 4 | 5 | ![Before](http://i.imgur.com/T3csYME.png) 6 | ![After](http://i.imgur.com/d0V0aO7.png) 7 | Look at the water and the jungle trunk at the center. 8 | 9 | 10 | ## minetest.conf settings 11 | * mapfix_default_size (by default 24) : size used when omitted 12 | * mapfix_max_size (by default 32) : maximum size allowed for players 13 | * mapfix_delay (by default 15) : minimal delay in seconds between 2 `/mapfix` (to avoid server freezing) 14 | * mapfix_priv (by default server) : priv that allows use of `/mapfix` without restrictions 15 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | local function mapfix(minp, maxp) 2 | local vm = minetest.get_voxel_manip(minp, maxp) 3 | vm:update_liquids() 4 | vm:write_to_map() 5 | vm:update_map() 6 | local emin, emax = vm:get_emerged_area() 7 | print(minetest.pos_to_string(emin), minetest.pos_to_string(emax)) 8 | end 9 | 10 | local previous = os.time() 11 | 12 | local default_size = tonumber(minetest.settings:get("mapfix_default_size")) or 24 13 | local max_size = tonumber(minetest.settings:get("mapfix_max_size")) or 32 14 | local delay = tonumber(minetest.settings:get("mapfix_delay")) or 15 15 | 16 | local function mapfix_priv() 17 | local priv = minetest.settings:get("mapfix_priv") 18 | 19 | if not minetest.registered_privileges[priv] then 20 | return "server" 21 | else 22 | return priv 23 | end 24 | end 25 | 26 | minetest.register_chatcommand("mapfix", { 27 | params = "", 28 | description = "Recalculate the flowing liquids and the light of a chunk", 29 | func = function(name, param) 30 | local pos = vector.round(minetest.get_player_by_name(name):getpos()) 31 | local size = tonumber(param) or default_size 32 | 33 | if size >= 121 then 34 | return false, "Radius is too big" 35 | end 36 | local privs = minetest.check_player_privs(name, mapfix_priv()) 37 | local time = os.time() 38 | 39 | if not privs then 40 | if size > max_size then 41 | return false, "You need the " .. mapfix_priv() .. " privilege to exceed the radius of " .. max_size .. " blocks" 42 | elseif time - previous < delay then 43 | return false, "Wait at least " .. delay .. " seconds from the previous \"/mapfix\"." 44 | end 45 | previous = time 46 | end 47 | 48 | minetest.log("action", 49 | name .. " uses mapfix at " .. minetest.pos_to_string(vector.round(pos)) .. " with radius " .. size) 50 | 51 | -- When passed to get_voxel_manip, positions are rounded up, to a multiple of 16 nodes in each direction. 52 | -- By subtracting 8 it's rounded to the nearest chunk border. max is used to avoid negative radius. 53 | size = math.max(math.floor(size - 8), 0) 54 | 55 | local minp = vector.subtract(pos, size) 56 | local maxp = vector.add(pos, size) 57 | 58 | mapfix(minp, maxp) 59 | return true, "Done." 60 | end, 61 | }) 62 | -------------------------------------------------------------------------------- /mod.conf: -------------------------------------------------------------------------------- 1 | name = mapfix 2 | description = Fix some map errors (flow and light problems) 3 | -------------------------------------------------------------------------------- /settingtypes.txt: -------------------------------------------------------------------------------- 1 | mapfix_default_size (default size a mapfix range is) int 24 2 | mapfix_max_size (max size a mapfix range can be) int 32 3 | mapfix_delay (delay between issueing of /mapfix for players) int 15 4 | mapfix_priv (priv for unrestricted /mapfix use) string server --------------------------------------------------------------------------------