forked from mtcontrib/replacer
fixed bug; added blacklist for nodes
This commit is contained in:
parent
9c80920cd8
commit
a535be2382
@ -2,15 +2,22 @@
|
|||||||
-- see http://forum.minetest.net/viewtopic.php?pid=26061 or https://github.com/VanessaE/homedecor for details!
|
-- see http://forum.minetest.net/viewtopic.php?pid=26061 or https://github.com/VanessaE/homedecor for details!
|
||||||
function replacer_homedecor_node_is_owned(pos, placer)
|
function replacer_homedecor_node_is_owned(pos, placer)
|
||||||
|
|
||||||
if type( minetest.is_protected == "function") then
|
if( not( placer ) or not(pos )) then
|
||||||
return minetest.is_protected( pos, placer:get_player_name() );
|
return true;
|
||||||
|
end
|
||||||
|
local pname = placer:get_player_name();
|
||||||
|
if (type( minetest.is_protected ) == "function") then
|
||||||
|
local res = minetest.is_protected( pos, pname );
|
||||||
|
if( res ) then
|
||||||
|
minetest.chat_send_player( pname, "Cannot replace node. It is protected." );
|
||||||
|
end
|
||||||
|
return res;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local ownername = false
|
local ownername = false
|
||||||
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
|
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
|
||||||
if HasOwner(pos, placer) then -- returns true if the node is owned
|
if HasOwner(pos, placer) then -- returns true if the node is owned
|
||||||
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
|
if not IsPlayerNodeOwner(pos, pname) then
|
||||||
if type(getLastOwner) == "function" then -- ...is an old version
|
if type(getLastOwner) == "function" then -- ...is an old version
|
||||||
ownername = getLastOwner(pos)
|
ownername = getLastOwner(pos)
|
||||||
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
|
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
|
||||||
@ -28,7 +35,7 @@ function replacer_homedecor_node_is_owned(pos, placer)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ownername ~= false then
|
if ownername ~= false then
|
||||||
minetest.chat_send_player( placer:get_player_name(), "Sorry, "..ownername.." owns that spot." )
|
minetest.chat_send_player( pname, "Sorry, "..ownername.." owns that spot." )
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
35
init.lua
35
init.lua
@ -21,6 +21,10 @@
|
|||||||
-- Version 3.0
|
-- Version 3.0
|
||||||
|
|
||||||
-- Changelog:
|
-- Changelog:
|
||||||
|
-- 09.12.2017 * Got rid of outdated minetest.env
|
||||||
|
-- * Fixed error in protection function.
|
||||||
|
-- * Fixed minor bugs.
|
||||||
|
-- * Added blacklist
|
||||||
-- 02.10.2014 * Some more improvements for inspect-tool. Added craft-guide.
|
-- 02.10.2014 * Some more improvements for inspect-tool. Added craft-guide.
|
||||||
-- 01.10.2014 * Added inspect-tool.
|
-- 01.10.2014 * Added inspect-tool.
|
||||||
-- 12.01.2013 * If digging the node was unsuccessful, then the replacement will now fail
|
-- 12.01.2013 * If digging the node was unsuccessful, then the replacement will now fail
|
||||||
@ -38,6 +42,19 @@ dofile(minetest.get_modpath("replacer").."/check_owner.lua");
|
|||||||
|
|
||||||
replacer = {};
|
replacer = {};
|
||||||
|
|
||||||
|
replacer.blacklist = {};
|
||||||
|
|
||||||
|
-- playing with tnt and creative building are usually contradictory
|
||||||
|
-- (except when doing large-scale landscaping in singleplayer)
|
||||||
|
replacer.blacklist[ "tnt:boom"] = true;
|
||||||
|
replacer.blacklist[ "tnt:gunpowder"] = true;
|
||||||
|
replacer.blacklist[ "tnt:gunpowder_burning"] = true;
|
||||||
|
replacer.blacklist[ "tnt:tnt"] = true;
|
||||||
|
|
||||||
|
-- prevent accidental replacement of your protector
|
||||||
|
replacer.blacklist[ "protector:protect"] = true;
|
||||||
|
replacer.blacklist[ "protector:protect2"] = true;
|
||||||
|
|
||||||
-- adds a tool for inspecting nodes and entities
|
-- adds a tool for inspecting nodes and entities
|
||||||
dofile(minetest.get_modpath("replacer").."/inspect.lua");
|
dofile(minetest.get_modpath("replacer").."/inspect.lua");
|
||||||
|
|
||||||
@ -158,6 +175,18 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
|
|||||||
return nil;
|
return nil;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if( node.name and node.name ~= "" and replacer.blacklist[ node.name ]) then
|
||||||
|
minetest.chat_send_player( name, "Replacing blocks of the type '"..( node.name or "?" )..
|
||||||
|
"' is not allowed on this server. Replacement failed.");
|
||||||
|
return nil;
|
||||||
|
end
|
||||||
|
|
||||||
|
if( replacer.blacklist[ daten[1] ]) then
|
||||||
|
minetest.chat_send_player( name, "Placing blocks of the type '"..( daten[1] or "?" )..
|
||||||
|
"' with the replacer is not allowed on this server. Replacement failed.");
|
||||||
|
return nil;
|
||||||
|
end
|
||||||
|
|
||||||
-- do not replace if there is nothing to be done
|
-- do not replace if there is nothing to be done
|
||||||
if( node.name == daten[1] ) then
|
if( node.name == daten[1] ) then
|
||||||
|
|
||||||
@ -170,12 +199,12 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- in survival mode, the player has to provide the node he wants to be placed
|
-- in survival mode, the player has to provide the node he wants to place
|
||||||
if( not(minetest.setting_getbool("creative_mode") )
|
if( not(minetest.setting_getbool("creative_mode") )
|
||||||
and not( minetest.check_player_privs( name, {creative=true}))) then
|
and not( minetest.check_player_privs( name, {creative=true}))) then
|
||||||
|
|
||||||
-- players usually don't carry dirt_with_grass around; it's safe to assume normal dirt here
|
-- players usually don't carry dirt_with_grass around; it's safe to assume normal dirt here
|
||||||
-- fortionately, dirt and dirt_with_grass does not make use of rotation
|
-- fortunately, dirt and dirt_with_grass does not make use of rotation
|
||||||
if( daten[1] == "default:dirt_with_grass" ) then
|
if( daten[1] == "default:dirt_with_grass" ) then
|
||||||
daten[1] = "default:dirt";
|
daten[1] = "default:dirt";
|
||||||
item["metadata"] = "default:dirt 0 0";
|
item["metadata"] = "default:dirt 0 0";
|
||||||
@ -196,6 +225,8 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
|
|||||||
and node.name ~= "ignore"
|
and node.name ~= "ignore"
|
||||||
and node.name ~= "default:lava_source"
|
and node.name ~= "default:lava_source"
|
||||||
and node.name ~= "default:lava_flowing"
|
and node.name ~= "default:lava_flowing"
|
||||||
|
and node.name ~= "default:river_water_source"
|
||||||
|
and node.name ~= "default:river_water_flowing"
|
||||||
and node.name ~= "default:water_source"
|
and node.name ~= "default:water_source"
|
||||||
and node.name ~= "default:water_flowing" ) then
|
and node.name ~= "default:water_flowing" ) then
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ replacer.inspect = function( itemstack, user, pointed_thing, mode, show_receipe
|
|||||||
text = text..'your fellow player \"'..tostring( ref:get_player_name() )..'\"';
|
text = text..'your fellow player \"'..tostring( ref:get_player_name() )..'\"';
|
||||||
else
|
else
|
||||||
local luaob = ref:get_luaentity();
|
local luaob = ref:get_luaentity();
|
||||||
if( luaob ) then
|
if( luaob and luaob.get_staticdata) then
|
||||||
text = text..'entity \"'..tostring( luaob.name )..'\"';
|
text = text..'entity \"'..tostring( luaob.name )..'\"';
|
||||||
local sdata = luaob:get_staticdata();
|
local sdata = luaob:get_staticdata();
|
||||||
if( sdata ) then
|
if( sdata ) then
|
||||||
|
Loading…
Reference in New Issue
Block a user