Add mapfix mod and some other things

This commit is contained in:
LoneWolfHT 2019-02-14 08:43:45 -08:00
parent 147e35f903
commit 99fdafbce4
7 changed files with 77 additions and 2 deletions

View File

@ -36,10 +36,12 @@ function game.start_dungeon(name, level)
game.dungeons = game.dungeons + 1
game.partyid = game.partyid + 1
for _, pname in ipairs(name) do
for pname in pairs(name) do
local player = minetest.get_player_by_name(pname)
local meta = player:get_meta()
player:set_pos(spawnpos)
minetest.chat_send_player(pname, "You are now in "..game.registered_dungeons[dname].description)
meta:set_string("location", "dungeon");
game.party[pname] = game.partyid
game.parties[game.partyid] = {[pname] = 1}
@ -52,6 +54,7 @@ end
function game.place_dungeon(name, pos)
for n, def in pairs(game.registered_dungeons) do
if n == name then
minetest.emerge_area(pos, vector.add(pos, def.size))
minetest.place_schematic(pos, def.path, def.rot, nil, true, nil)
return "Dungeon placed"
end

View File

@ -2,9 +2,11 @@ map = {}
function map.place_lobby()
minetest.log("Placing lobby...")
local pos = {x = 0, y = 0, z = 0}
local path = minetest.get_modpath("map") .. "/schematics/lobby.mts"
minetest.place_schematic({x = 0, y = 0, z = 0}, path, "0", nil, true)
minetest.emerge_area(pos, vector.add(pos, 250))
minetest.place_schematic(pos, path, "0", nil, true)
minetest.log("Done placing lobby...")

4
mods/mapfix/LICENSE Normal file
View File

@ -0,0 +1,4 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
See http://www.gnu.org/licenses/gpl-3.0.en.html

13
mods/mapfix/README.md Normal file
View File

@ -0,0 +1,13 @@
# mapfix
Fix some map errors (flow and light problems)
![Before](http://i.imgur.com/T3csYME.png)
![After](http://i.imgur.com/d0V0aO7.png)
Look at the water and the jungle trunk at the center.
## minetest.conf settings
* mapfix_default_size (by default 24) : size used when omitted
* mapfix_max_size (by default 32) : maximum size allowed for players
* mapfix_delay (by default 15) : minimal delay in seconds between 2 `/mapfix` (to avoid server freezing)

View File

@ -0,0 +1 @@
Fix some map errors (flow and light problems)

51
mods/mapfix/init.lua Normal file
View File

@ -0,0 +1,51 @@
local function mapfix(minp, maxp)
local vm = minetest.get_voxel_manip(minp, maxp)
vm:update_liquids()
vm:write_to_map()
vm:update_map()
local emin, emax = vm:get_emerged_area()
print(minetest.pos_to_string(emin), minetest.pos_to_string(emax))
end
local previous = os.time()
local default_size = tonumber(minetest.settings:get("mapfix_default_size")) or 100
local max_size = tonumber(minetest.settings:get("mapfix_max_size")) or 100
local delay = tonumber(minetest.settings:get("mapfix_delay")) or 15
minetest.register_chatcommand("mapfix", {
params = "<size>",
description = "Recalculate the flowing liquids and the light of a chunk",
func = function(name, param)
local pos = vector.round(minetest.get_player_by_name(name):getpos())
local size = tonumber(param) or default_size
if size >= 121 then
return false, "Radius is too big"
end
local privs = minetest.check_player_privs(name, {server=true})
local time = os.time()
if not privs then
if size > max_size then
return false, "You need the server privilege to exceed the radius of " .. max_size .. " blocks"
elseif time - previous < delay then
return false, "Wait at least " .. delay .. " seconds from the previous \"/mapfix\"."
end
previous = time
end
minetest.log("action", name .. " uses mapfix at " .. minetest.pos_to_string(vector.round(pos)) ..
" with radius ".. size)
size = math.max(math.floor(size - 8), 0) -- When passed to get_voxel_manip, positions are rounded up, to a
--multiple of 16 nodes in each direction. By subtracting 8 it's rounded to the nearest chunk border. max is
--used to avoid negative radius.
local minp = vector.subtract(pos, size)
local maxp = vector.add(pos, size)
mapfix(minp, maxp)
return true, "Done."
end,
})

1
mods/mapfix/mod.conf Normal file
View File

@ -0,0 +1 @@
name = mapfix