diff --git a/mods/peace_areas/init.lua b/mods/peace_areas/init.lua new file mode 100644 index 00000000..f9ed8a88 --- /dev/null +++ b/mods/peace_areas/init.lua @@ -0,0 +1,47 @@ +-- +-- Peaceful areas +-- Where hitting is impossible +-- + +peace_areas = {areas = {}} + +minetest.register_on_punchplayer(function(player, hitter) + local pos = player:getpos() + for name, positions in pairs(peace_areas.areas) do + local pos1 = positions["pos1"] + local pos2 = positions["pos2"] + local minp = { + x = math.min(pos1.x, pos2.x), + y = math.min(pos1.y, pos2.y), + z = math.min(pos1.z, pos2.z) + } + local maxp = { + x = math.max(pos1.x, pos2.x), + y = math.max(pos1.y, pos2.y), + z = math.max(pos1.z, pos2.z) + } + if minp.x < pos.x and pos.x < maxp.x and + minp.y < pos.y and pos.y < maxp.y and + minp.z < pos.z and pos.z < maxp.z then + if hitter:is_player() then + minetest.chat_send_player(hitter:get_player_name(), "You cannot punch player " .. + player:get_player_name() .. ". They are in area " .. name .. ".") + end + return true + --[[ + Note: + This use of the callback register_on_punchplayer may prevent other + instance of it to work correctly. Please take note of it. + ]]-- + end + end +end) + +function peace_areas.register_house(area_name, def) + peace_areas.areas[area_name] = def +end + +peace_areas.register_area("spawn", { + ["pos1"] = {x = 16, y = 0, z = 12}, + ["pos2"] = {x = 42, y = 100, z = -14}, +}) diff --git a/worlds/minetestforfun/news.txt b/worlds/minetestforfun/news.txt index bb1771ac..e46c47f6 100755 --- a/worlds/minetestforfun/news.txt +++ b/worlds/minetestforfun/news.txt @@ -8,12 +8,15 @@ Ca y est, les classes Warrior et Hunter sont là ! (Venez les tester et aider no Venez visiter notre nouveau site "minetestforfun.com" ! ---Patch Notes--- +---??/??/????--- (Thanks to : LeMagnesium/Mg) +Addition of "peace_areas" (prevent players from punching each other in the spawn area) + ---24/08/2015--- (Thanks to : crabman77/crabman, LeMagnesium/Mg) Update of "mobs" (Minotaur monster isn't anymore damaged by water) Update of "biome_lib " (Fix again the sapling growth) ---23/08/2015--- (Thanks to : LeMagnesium/Mg, crabman77/crabman) -Removed of "3dchest" (too many work to debug/adapt it, we can't work so hard for just an animated 1x1 or 2x1 chest) +Removal of "3dchest" (too many work to debug/adapt it, we can't work so hard for just an animated 1x1 or 2x1 chest) Update of "moretrees" (Fix sapling growth) Update of "moreblocks" (Fix the bricks nodes drops from the moreblocks circulsaw) diff --git a/worlds/minetestforfun/world.mt b/worlds/minetestforfun/world.mt index 6bb6bb83..ff6aa956 100755 --- a/worlds/minetestforfun/world.mt +++ b/worlds/minetestforfun/world.mt @@ -24,6 +24,7 @@ load_mod_automappercolors = true load_mod_mapfix = true load_mod_worldedge = true load_mod_maze = true +load_mod_peace_areas = true load_mod_watershed = true load_mod_bushes_classic = true