Version MFF.

This commit is contained in:
sys4-fr 2018-09-08 00:36:44 +02:00
parent 52d1b90b89
commit 3a36c425da
10 changed files with 58 additions and 58 deletions

0
README.md Normal file → Executable file
View File

92
areas.lua Normal file → Executable 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
@ -483,32 +483,32 @@ markers.form_input_handler_areas = function( player, formname, fields)
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

0
depends.txt Normal file → Executable file
View File

10
init.lua Normal file → Executable 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 ) then
if( n > markers.MAX_MARKERS and minetest.get_player_privs(name)["megabuilder"] ~= true) 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 ) then
if( markers.MAX_SIZE < size and minetest.get_player_privs(name)["megabuilder"] ~= true) 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 ) then
if( not( add_height ) or add_height < 0 or (add_height > markers.MAX_HEIGHT and minetest.get_player_privs(name)["megabuilder"] ~= true)) 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 ) then
elseif( not( add_depth ) or add_depth < 0 or (add_depth > markers.MAX_HEIGHT and minetest.get_player_privs(name)["megabuilder"] ~= true)) 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 ) then
elseif( add_height + add_depth > markers.MAX_HEIGHT ) and minetest.get_player_privs(name)["megabuilder"] ~= true 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 )..'.'

14
land_title_register.lua Normal file → Executable file
View File

@ -3,7 +3,7 @@
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},
@ -14,9 +14,9 @@ minetest.register_tool( "markers:land_title_register",
full_punch_interval = 1.0,
max_drop_level=0,
groupcaps={
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}
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}
}
},
node_placement_prediction = nil,
@ -30,7 +30,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 +41,7 @@ minetest.register_tool( "markers:land_title_register",
return itemstack; -- nothing consumed, nothing changed
end,
on_use = function(itemstack, placer, pointed_thing)
@ -51,7 +51,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 Normal file → Executable file
View File

BIN
textures/compass_side_top.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 684 B

After

Width:  |  Height:  |  Size: 471 B

BIN
textures/markers_mark.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 B

After

Width:  |  Height:  |  Size: 281 B

BIN
textures/markers_stone.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

After

Width:  |  Height:  |  Size: 686 B

BIN
textures/markers_stone_side.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 B

After

Width:  |  Height:  |  Size: 743 B