From 01234ecd2bca88554d68d9f9410b8c6cee30f536 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sat, 5 Sep 2015 17:50:38 +0200 Subject: [PATCH] split config values into new config.lua; added markers.AREA_RANGE in order to restrict the amount of areas shown on big servers --- areas.lua | 22 ++++++++++++++++++---- config.lua | 21 +++++++++++++++++++++ init.lua | 19 +------------------ 3 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 config.lua diff --git a/areas.lua b/areas.lua index 8daa0fa..f804f7f 100644 --- a/areas.lua +++ b/areas.lua @@ -92,22 +92,36 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se -- show only areas that do not have parents elseif( mode=='main_areas' ) then - title = 'All main areas:'; + title = 'All main areas withhin '..tostring( markers.AREA_RANGE )..' m:'; tlabel = '*all main areas*'; for id, area in pairs(areas.areas) do - if( not( area.parent )) then + if( not( area.parent ) + -- ppos is always available + and( (area.pos1.x >= ppos.x-markers.AREA_RANGE and area.pos1.x <= ppos.x+markers.AREA_RANGE ) + or(area.pos2.x >= ppos.x-markers.AREA_RANGE and area.pos2.x <= ppos.x+markers.AREA_RANGE )) + and( (area.pos1.y >= ppos.y-markers.AREA_RANGE and area.pos1.y <= ppos.y+markers.AREA_RANGE ) + or(area.pos2.y >= ppos.y-markers.AREA_RANGE and area.pos2.y <= ppos.y+markers.AREA_RANGE )) + and( (area.pos1.z >= ppos.z-markers.AREA_RANGE and area.pos1.z <= ppos.z+markers.AREA_RANGE ) + or(area.pos2.z >= ppos.z-markers.AREA_RANGE and area.pos2.z <= ppos.z+markers.AREA_RANGE ))) then table.insert( id_list, id ); end end elseif( mode=='all' ) then - title = 'All areas:'; + title = 'All areas withhin '..tostring( markers.AREA_RANGE )..' m:'; tlabel = '*all areas*'; for id, area in pairs(areas.areas) do - table.insert( id_list, id ); + if( ( (area.pos1.x >= ppos.x-markers.AREA_RANGE and area.pos1.x <= ppos.x+markers.AREA_RANGE ) + or(area.pos2.x >= ppos.x-markers.AREA_RANGE and area.pos2.x <= ppos.x+markers.AREA_RANGE )) + and( (area.pos1.y >= ppos.y-markers.AREA_RANGE and area.pos1.y <= ppos.y+markers.AREA_RANGE ) + or(area.pos2.y >= ppos.y-markers.AREA_RANGE and area.pos2.y <= ppos.y+markers.AREA_RANGE )) + and( (area.pos1.z >= ppos.z-markers.AREA_RANGE and area.pos1.z <= ppos.z+markers.AREA_RANGE ) + or(area.pos2.z >= ppos.z-markers.AREA_RANGE and area.pos2.z <= ppos.z+markers.AREA_RANGE ))) then + table.insert( id_list, id ); + end end end diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..d1ce1dd --- /dev/null +++ b/config.lua @@ -0,0 +1,21 @@ + +-- stores up to 4 marker positions for each player +markers.positions = {} + +-- store the positions of that many markers for each player (until server restart) +markers.MAX_MARKERS = 50; + +-- the protection against digging of the marker by other players expires after this time +markers.EXPIRE_AFTER = 60*60*24; + +-- self-protected areas can not get higher than 100 blocks +markers.MAX_HEIGHT = 100; + +-- only areas up to this size (in square meters) can be protected +markers.MAX_SIZE = 1024; -- 32m * 32m = 1024 m^2 + +-- show only areas withhin this range when showing the list of ALL areas +-- (else it does get too crowded on multiplayer servers) +-- set to something >60000 in order to view all areas; set to a smaller +-- value (i.e. 500) on multiplayer servers with many protected areas +markers.AREA_RANGE = 100000; diff --git a/init.lua b/init.lua index a228bee..2e72af0 100644 --- a/init.lua +++ b/init.lua @@ -5,26 +5,9 @@ markers = {} --- stores up to 4 marker positions for each player -markers.positions = {} - --- store the positions of that many markers for each player (until server restart) -markers.MAX_MARKERS = 50; - --- the protection against digging of the marker by other players expires after this time -markers.EXPIRE_AFTER = 60*60*24; - --- self-protected areas can not get higher than 100 blocks -markers.MAX_HEIGHT = 100; - --- only areas up to this size (in square meters) can be protected -markers.MAX_SIZE = 1024; -- 32m * 32m = 1024 m^2 - - +dofile(minetest.get_modpath("markers").."/config.lua"); dofile(minetest.get_modpath("markers").."/areas.lua"); - dofile(minetest.get_modpath("markers").."/marker_stone.lua"); - dofile(minetest.get_modpath("markers").."/land_title_register.lua");