Compare commits

10 Commits

Author SHA1 Message Date
a71fd2fd15 Merge branch 'blaboing-patch-1' 2023-01-22 22:48:47 +01:00
3d13feb605 merged mod.conf 2023-01-22 22:48:23 +01:00
40090995b8 Merge pull request #12 from zeuner/integration
add mod.conf
2023-01-22 22:46:12 +01:00
6c73bdd8c4 Merge pull request #8 from nanepiwo/patch-1
Add dependency
2023-01-22 22:45:26 +01:00
d2091badd7 replaced deprecated getpos function 2023-01-22 22:43:47 +01:00
2aa8284558 add missing mod.conf 2023-01-20 22:02:20 +01:00
d79a7eaa2d add mod.conf 2017-10-10 09:48:09 +02:00
ad3c999f64 made compatible with newest version of MT 2017-07-04 20:54:54 +02:00
c09e8c0e1c use settings instead of dofile; increased max area size by factor 4 2017-05-16 03:18:08 +02:00
6d3db925a0 Add dependency
It depends on default to craft the markers and area stones :)
2015-05-25 21:17:47 -04:00
13 changed files with 99 additions and 63 deletions

0
README.md Executable file → Normal file
View File

94
areas.lua Executable file → Normal file
View File

@ -107,7 +107,7 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se
table.insert( id_list, id );
end
end
elseif( mode=='all' ) then
title = 'All areas withhin '..tostring( markers.AREA_RANGE )..' m:';
@ -142,7 +142,7 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se
"label[4.7,0;"..tlabel.."]"..
"label[0.5,8.5;Doubleclick to select area.]"..
"label[4.7,8.5;Areas found: "..tostring( #id_list )..".]"..
"textlist[0.5,0.5;7,8;markers_area_list_selection;";
"textlist[0.5,0.5;7,8;markers_area_list_selection;";
local liste = '';
for i,v in ipairs( id_list ) do
@ -150,7 +150,7 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se
liste = liste..',';
end
liste = liste..minetest.formspec_escape( areas:toString( v ) );
end
-- highlight selected entry
@ -159,14 +159,14 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se
else
formspec = formspec..liste..';]';
end
local pname = player:get_player_name();
if( not( markers.menu_data_by_player[ pname ] )) then
markers.menu_data_by_player[ pname ] = {};
end
-- display information about the location of the area the player clicked on
if( selected
if( selected
and id_list[ selected ]
and areas.areas[ id_list[ selected ]] ) then
@ -185,7 +185,7 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se
if( this_area.parent) then
formspec = formspec..
'button[8.0,0.5;2,0.5;show_parent;'..
'button[8.0,0.5;2,0.5;show_parent;'..
minetest.formspec_escape( areas.areas[ this_area.parent ].name )..']';
end
@ -194,7 +194,7 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se
'button[8.0,1.0;2,0.5;list_subareas;'..
minetest.formspec_escape( 'List subareas ('..tostring( #subareas )..')')..']';
end
if( mode=='player' ) then
formspec = formspec..
@ -222,8 +222,8 @@ markers.get_area_list_formspec = function(ppos, player, mode, pos, mode_data, se
selected = id_list[ selected ],
};
return formspec;
end
@ -278,7 +278,7 @@ markers.get_area_desc_formspec = function( id, player, pos )
and this_area.parent
and areas.areas[ this_area.parent ]
and areas.areas[ this_area.parent ].owner == pname ) then
formspec = formspec..
'button_exit[8.0,1.0;2,0.5;delete;Delete subarea]'..
'button_exit[8.0,2.0;2,0.5;list_player_areas;Player\'s areas]';
@ -325,12 +325,12 @@ markers.get_area_desc_formspec = function( id, player, pos )
else
formspec = formspec..
'label[4.7,2.5;-none-]';
if( is_owner ) then
formspec = formspec..
'button_exit[8.0,2.5;2,0.5;add_owner;Add]';
end
end
end
-- is the area a subarea?
@ -340,7 +340,7 @@ markers.get_area_desc_formspec = function( id, player, pos )
'label[4.7,3.0;'..minetest.formspec_escape( areas.areas[ this_area.parent ].name..' ['..this_area.parent..']' )..']'..
'button_exit[8.0,3.0;2,0.5;show_parent;Show main area]';
end
-- does the area have subareas, i.e. is it a parent area for others?
local sub_areas = {};
@ -391,14 +391,14 @@ markers.get_area_desc_formspec = function( id, player, pos )
-- player selected
markers.menu_data_by_player[ pname ] =
{ typ = 'show_area',
mode = nil,
mode = nil,
pos = pos,
mode_data = nil,
list = nil,
selected = id,
};
return formspec;
end
@ -413,10 +413,10 @@ markers.show_compass_marker = function( col_offset, row_offset, with_text, pos,
-- TODO: what if checked with a land claim register?
-- if possible, show how far the area streches into each direction relative to pos
if( pos.x >= pos1.x and pos.x <= pos2.x
and pos.y >= pos1.y and pos.y <= pos2.y
if( pos.x >= pos1.x and pos.x <= pos2.x
and pos.y >= pos1.y and pos.y <= pos2.y
and pos.z >= pos1.z and pos.z <= pos2.z ) then
if( with_text ) then
formspec = formspec..
'label[0.5,5.5;Dimensions of the area in relation to..]'..
@ -468,7 +468,7 @@ markers.show_compass_marker = function( col_offset, row_offset, with_text, pos,
'label['..(col_offset+0.1)..','..(row_offset-0.80)..';'..starts_north..']'..
'label['..(col_offset+0.1)..','..(row_offset+0.80)..';'..starts_south..']';
end
return formspec;
end
@ -478,37 +478,37 @@ end
markers.form_input_handler_areas = function( player, formname, fields)
local pname = player:get_player_name();
local ppos = player:getpos()
local ppos = player:get_pos()
if( formname ~= "markers:info"
or not( player )
or not( markers.menu_data_by_player[ pname ] )) then
return false;
end
local menu_data = markers.menu_data_by_player[ pname ];
local formspec = '';
-- rename an area
if( fields.rename
if( fields.rename
and menu_data.selected
and areas.areas[ menu_data.selected ]
and areas.areas[ menu_data.selected ].owner == pname ) then
local area = areas.areas[ menu_data.selected ];
if( not( area.name )) then
area.name = '-enter area name-';
end
formspec = 'field[rename_new_name;Enter new name for area:;'..minetest.formspec_escape( area.name )..']';
elseif( fields.rename_new_name
elseif( fields.rename_new_name
and menu_data.selected
and areas.areas[ menu_data.selected ]
and ((areas.areas[ menu_data.selected ].owner == pname )
and ((areas.areas[ menu_data.selected ].owner == pname )
or minetest.check_player_privs(pname, {areas=true}))) then
local area = areas.areas[ menu_data.selected ];
-- actually rename the area
@ -525,7 +525,7 @@ markers.form_input_handler_areas = function( player, formname, fields)
elseif( fields.change_owner
and menu_data.selected
and areas.areas[ menu_data.selected ] ) then
-- there are no checks here - those happen when the area is transferred
local area = areas.areas[ menu_data.selected ];
formspec = 'field[change_owner_name;Give area \"'..minetest.formspec_escape( area.name )..'\" to player:;-enter name of NEW OWNER-]';
@ -537,9 +537,9 @@ markers.form_input_handler_areas = function( player, formname, fields)
local area = areas.areas[ menu_data.selected ];
-- only own areas can be transfered to another player (or if the areas priv is there)
if( area.owner ~= pname
if( area.owner ~= pname
and not( minetest.check_player_privs(pname, {areas=true}))) then
minetest.chat_send_player( pname, 'Permission denied. You do not own the area.');
elseif( not( areas:player_exists( fields.change_owner_name ))) then
@ -564,11 +564,11 @@ markers.form_input_handler_areas = function( player, formname, fields)
and menu_data.selected
and areas.areas[ menu_data.selected ]
and areas.areas[ menu_data.selected ].owner == pname ) then
local area = areas.areas[ menu_data.selected ];
formspec = 'field[add_owner_name;Grant access to area \"'..minetest.formspec_escape( area.name )..'\" to player:;-enter player name-]';
elseif( fields.add_owner_name
elseif( fields.add_owner_name
-- the player has to own the area already; we need a diffrent name here
and fields.add_owner_name ~= pname
and menu_data.selected
@ -608,20 +608,20 @@ markers.form_input_handler_areas = function( player, formname, fields)
-- delete area
elseif( fields.delete
elseif( fields.delete
and menu_data.selected
and areas.areas[ menu_data.selected ] ) then
local area = areas.areas[ menu_data.selected ];
-- a player can only delete own areas or subareas of own areas
if( area.owner ~= pname
and not( area.parent
and areas.areas[ area.parent ]
if( area.owner ~= pname
and not( area.parent
and areas.areas[ area.parent ]
and areas.areas[ area.parent ].owner
and areas.areas[ area.parent ].owner == pname )
and not( minetest.check_player_privs(pname, {areas=true}))) then
minetest.chat_send_player( pname, 'Permission denied. You own neither the area itshelf nor its parent area.');
-- shwo the area where the renaming failed
formspec = markers.get_area_desc_formspec( menu_data.selected, player, menu_data.pos );
@ -634,10 +634,10 @@ markers.form_input_handler_areas = function( player, formname, fields)
end
elseif( fields.delete_confirm
elseif( fields.delete_confirm
and menu_data.selected
and areas.areas[ menu_data.selected ] ) then
local area = areas.areas[ menu_data.selected ];
local old_owner = area.owner;
@ -649,13 +649,13 @@ markers.form_input_handler_areas = function( player, formname, fields)
end
-- a player can only delete own areas or subareas of own areas
if( area.owner ~= pname
and not( area.parent
and areas.areas[ area.parent ]
if( area.owner ~= pname
and not( area.parent
and areas.areas[ area.parent ]
and areas.areas[ area.parent ].owner
and areas.areas[ area.parent ].owner == pname )
and not( minetest.check_player_privs(pname, {areas=true}))) then
minetest.chat_send_player( pname, 'Permission denied. You own neither the area itshelf nor its parent area.');
-- shwo the renamed area
formspec = markers.get_area_desc_formspec( menu_data.selected, player, menu_data.pos );
@ -666,7 +666,7 @@ markers.form_input_handler_areas = function( player, formname, fields)
formspec = markers.get_area_desc_formspec( menu_data.selected, player, menu_data.pos );
-- only areas without subareas can be deleted
elseif( #subareas > 0 ) then
elseif( #subareas > 0 ) then
minetest.chat_send_player( pname, 'The area has '..tostring( #subareas )..' subarea(s). Please delete those first!');
formspec = markers.get_area_desc_formspec( menu_data.selected, player, menu_data.pos );
@ -707,7 +707,7 @@ markers.form_input_handler_areas = function( player, formname, fields)
elseif( fields.list_main_areas ) then
formspec = markers.get_area_list_formspec(ppos, player, 'main_areas', menu_data.pos, nil, nil );
elseif( fields.list_areas_at
and menu_data.pos ) then
@ -754,7 +754,7 @@ markers.show_marker_stone_formspec = function( player, pos )
local pname = player:get_player_name();
local ppos = pos
-- this table stores the list the player may have selected from; at the beginning, there is no list
-- this table stores the list the player may have selected from; at the beginning, there is no list
if( not( markers.menu_data_by_player[ pname ] )) then
markers.menu_data_by_player[ pname ] = {
typ = 'area_list',
@ -801,7 +801,7 @@ markers.show_marker_stone_formspec = function( player, pos )
'label[0.5,0.5;This position is not protected.]'..
'button[1.0,1.5;2,0.5;list_main_areas;List all main areas]'..
'button_exit[3.0,1.5;1,0.5;abort;OK]';
-- found exactly one areaa - display it
elseif( #found_areas == 1 ) then

View File

@ -12,7 +12,7 @@ markers.EXPIRE_AFTER = 60*60*24;
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
markers.MAX_SIZE = 4096; -- 64m * 64m= 4096 m^2
-- show only areas withhin this range when showing the list of ALL areas
-- (else it does get too crowded on multiplayer servers)
@ -30,7 +30,18 @@ end
-- for most cases, the default values ought to work
--markers.AREA_RANGE = 100000;
if( io.open(minetest.get_worldpath().."/markers_settings.txt","r")) then
io.close()
dofile(minetest.get_worldpath().."/markers_settings.txt")
local settings = Settings( minetest.get_worldpath().."/markers_settings.txt");
if( settings ) then
if( settings:get( "markers_MAX_MARKERS" )) then
markers.MAX_MARKERS = tonumber(settings:get( "markers_MAX_MARKERS"));
end
if( settings:get( "markers_EXPIRE_AFTER" )) then
markers.EXPIRE_AFTER = tonumber(settings:get( "markers_EXPIRE_AFTER"));
end
if( settings:get( "markers_MAX_HEIGHT" )) then
markers.MAX_HEIGHT = tonumber(settings:get( "markers_MAX_HEIGHT"));
end
if( settings:get( "markers_MAX_SIZE" )) then
markers.MAX_SIZE = tonumber(settings:get( "markers_MAX_SIZE"));
end
end

1
depends.txt Executable file → Normal file
View File

@ -1 +1,2 @@
areas
default

10
init.lua Executable file → Normal file
View File

@ -128,7 +128,7 @@ markers.marker_placed = function( pos, placer, itemstack )
end
-- make sure the list does not grow too large
if( n > markers.MAX_MARKERS and minetest.get_player_privs(name)["megabuilder"] ~= true) then
if( n > markers.MAX_MARKERS ) then
table.remove( markers.positions[ name ], 1 );
end
end
@ -284,7 +284,7 @@ markers.get_marker_formspec = function(player, pos, error_msg)
* (math.abs( coords[1].z - coords[2].z )+1);
-- check if area is too large
if( markers.MAX_SIZE < size and minetest.get_player_privs(name)["megabuilder"] ~= true) then
if( markers.MAX_SIZE < size ) then
return formspec_info.."Error: You can only protect\nareas of up to "..tostring( markers.MAX_SIZE ).."m^2.\n"..
"Your marked area is "..tostring( size ).." m^2 large.]";
end
@ -374,19 +374,19 @@ markers.marker_on_receive_fields = function(pos, formname, fields, sender)
local add_depth = tonumber( fields['add_depth'] );
local error_msg = '';
if( not( add_height ) or add_height < 0 or (add_height > markers.MAX_HEIGHT and minetest.get_player_privs(name)["megabuilder"] ~= true)) then
if( not( add_height ) or add_height < 0 or add_height > markers.MAX_HEIGHT ) then
minetest.chat_send_player( name, 'Please enter a number between 0 and '..tostring( markers.MAX_HEIGHT )..
' in the field where the height of your area is requested. Your area will stretch that many blocks '..
'up into the sky from the position of this marker onward.');
error_msg = 'The height value\nhas to be larger than 0\nand smaller than '..tostring( markers.MAX_HEIGHT );
elseif( not( add_depth ) or add_depth < 0 or (add_depth > markers.MAX_HEIGHT and minetest.get_player_privs(name)["megabuilder"] ~= true)) then
elseif( not( add_depth ) or add_depth < 0 or add_depth > markers.MAX_HEIGHT ) then
minetest.chat_send_player( name, 'Please enter a number between 0 and '..tostring( markers.MAX_HEIGHT )..
' in the field where the depth of your area is requested. Your area will stretch that many blocks '..
'into the ground from the position of this marker onward.');
error_msg = 'The depth value\nhas to be larger than 0\nand smaller than '..tostring( markers.MAX_HEIGHT );
elseif( add_height + add_depth > markers.MAX_HEIGHT ) and minetest.get_player_privs(name)["megabuilder"] ~= true then
elseif( add_height + add_depth > markers.MAX_HEIGHT ) then
minetest.chat_send_player( name, 'Sorry, your area exceeds the height limit. Height and depth added have to '..
'be smaller than '..tostring( markers.MAX_HEIGHT )..'.');
error_msg = 'height + depth has to\nbe smaller than '..tostring( markers.MAX_HEIGHT )..'.'

16
land_title_register.lua Executable file → Normal file
View File

@ -3,22 +3,24 @@
minetest.register_tool( "markers:land_title_register",
{
description = "Land title register. Left-click with it to get information about who owns the land you clicked on.",
groups = {},
groups = {},
inventory_image = "default_book.png", -- TODO
wield_image = "",
wield_scale = {x=1,y=1,z=1},
stack_max = 1, -- there is no need to have more than one
liquids_pointable = true, -- ground with only water on can be owned as well
--[[
-- the tool_capabilities are completely irrelevant here - no need to dig
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=0,
groupcaps={
fleshy={times={[2]=0.80, [3]=0.40}, uses = 1/0.05, maxlevel=1},
snappy={times={[2]=0.80, [3]=0.40}, uses = 1/0.05, maxlevel=1},
choppy={times={[3]=0.90}, uses = 1/0.05, maxlevel=0}
fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
}
},
--]]
node_placement_prediction = nil,
on_place = function(itemstack, placer, pointed_thing)
@ -30,7 +32,7 @@ minetest.register_tool( "markers:land_title_register",
-- the position is what we're actually looking for
local pos = minetest.get_pointed_thing_position( pointed_thing, false ); -- not above
if( not( pos ) or not( pos.x )) then
minetest.chat_send_player( name, "Position not found.");
return itemstack;
@ -41,7 +43,7 @@ minetest.register_tool( "markers:land_title_register",
return itemstack; -- nothing consumed, nothing changed
end,
on_use = function(itemstack, placer, pointed_thing)
@ -51,7 +53,7 @@ minetest.register_tool( "markers:land_title_register",
local name = placer:get_player_name();
local pos = minetest.get_pointed_thing_position( pointed_thing, false ); -- not above
if( not( pos ) or not( pos.x )) then
minetest.chat_send_player( name, "Position not found.");
return itemstack;

0
marker_stone.lua Executable file → Normal file
View File

19
markers_settings.txt Normal file
View File

@ -0,0 +1,19 @@
# copy this to your worldpath if you want to override these values
# store the positions of that many markers for each player (until server restart)
# default: 50
markers_MAX_MARKERS = 50
# the protection against digging of the marker by other players expires after this time
# default: 60*60*24 (1 day)
markers_EXPIRE_AFTER = 86400
# self-protected areas can not get higher than this
# default: 100
markers_MAX_HEIGHT = 100
# only areas up to this size (in square meters) can be protected
# default: 4096
markers_MAX_SIZE = 4096

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = markers
description = markers for the Minetest mod "areas"
depends = areas

BIN
textures/compass_side_top.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 684 B

BIN
textures/markers_mark.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 377 B

BIN
textures/markers_stone.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

After

Width:  |  Height:  |  Size: 793 B

BIN
textures/markers_stone_side.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 743 B

After

Width:  |  Height:  |  Size: 832 B