Closed fireglow closed 7 years ago
That would prevent admins/moderators with give privilege to use the replacer for private purposes though. :-1: It should only happen in creative mode, which it already does.
Idea: If the user has the creative privilege, don't require the items needed in the replace operation to have to be in the inventory. They could just be spawned out of the ether. This would remove some tedious searching of node names.
| Napiophelios, it already works this way in creative mode.
creative mode advantages extend into survival mode for whomever has the creative privilege.
I think the creative.is_enabled_for function fits best.
fireglow, testing for the give privilege would have the disadvantage that it's inconsistent with usual placing, for comparison with creative privilege players don't loose items when placing them without replacer
I solved this years ago with a local edit.
diff --git a/init.lua b/init.lua
index 83cb463..ca4baba 100644
--- a/init.lua
+++ b/init.lua
@@ -44,7 +44,8 @@ dofile(minetest.get_modpath("replacer").."/inspect.lua");
minetest.register_tool( "replacer:replacer",
{
description = "Node replacement tool",
- groups = {},
+ groups = {},
+ range = 20,
inventory_image = "replacer_replacer.png",
wield_image = "",
wield_scale = {x=1,y=1,z=1},
@@ -170,24 +171,15 @@ replacer.replace = function( itemstack, user, pointed_thing, mode )
-- in survival mode, the player has to provide the node he wants to be placed
if( not(minetest.setting_getbool("creative_mode") )) then
-
- -- 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
- if( daten[1] == "default:dirt_with_grass" ) then
- daten[1] = "default:dirt";
- item["metadata"] = "default:dirt 0 0";
- end
-
- -- does the player carry at least one of the desired nodes with him?
- if( not( user:get_inventory():contains_item("main", daten[1]))) then
-
- minetest.chat_send_player( name, "You have no further '"..( daten[1] or "?" ).."'. Replacement failed.");
- return nil;
+ if( not(minetest.check_player_privs(name, "give")) ) then
+ -- does the player carry at least one of the desired nodes with him?
+ if( not( user:get_inventory():contains_item("main", daten[1]))) then
+ minetest.chat_send_player( name, "You have no further '"..( daten[1] or "?" ).."'. Replacement failed.");
+ return nil;
+ end
end
-
-
-- give the player the item by simulating digging if possible
if( node.name ~= "air"
and node.name ~= "ignore"
Idea: If the user has the give privilege, don't require the items needed in the replace operation to have to be in the inventory. They could just be spawned out of the ether. This would remove some tedious searching of node names.