54 lines
1.8 KiB
Lua
54 lines
1.8 KiB
Lua
-- Admin replacer extension for Sokomine's replacer mod
|
|
-- range was added and texture updated.
|
|
-- Everything else below is code by Sokomine.
|
|
minetest.register_tool( ":replacer:replacer_admin",
|
|
{
|
|
description = "Admin node replacement tool",
|
|
groups = {},
|
|
inventory_image = "replacer_replacer_admin.png",
|
|
wield_image = "",
|
|
wield_scale = {x=1,y=1,z=1},
|
|
stack_max = 1, -- it has to store information - thus only one can be stacked
|
|
liquids_pointable = true, -- it is ok to painit in/with water
|
|
node_placement_prediction = nil,
|
|
metadata = "default:dirt", -- default replacement: common dirt
|
|
range = 12,
|
|
on_place = function(itemstack, placer, pointed_thing)
|
|
|
|
if( placer == nil or pointed_thing == nil) then
|
|
return itemstack; -- nothing consumed
|
|
end
|
|
local name = placer:get_player_name();
|
|
|
|
local keys=placer:get_player_control();
|
|
|
|
if( not( keys["sneak"] )) then
|
|
|
|
return replacer.replace( itemstack, placer, pointed_thing, 0 ); end
|
|
|
|
|
|
if( pointed_thing.type ~= "node" ) then
|
|
minetest.chat_send_player( name, " Error: No node selected.");
|
|
return nil;
|
|
end
|
|
|
|
local pos = minetest.get_pointed_thing_position( pointed_thing, under );
|
|
local node = minetest.env:get_node_or_nil( pos );
|
|
|
|
local metadata = "default:dirt 0 0";
|
|
if( node ~= nil and node.name ) then
|
|
metadata = node.name..' '..node.param1..' '..node.param2;
|
|
end
|
|
itemstack:set_metadata( metadata );
|
|
|
|
minetest.chat_send_player( name, "Node replacement tool set to: '"..metadata.."'.");
|
|
|
|
return itemstack; -- nothing consumed but data changed
|
|
end,
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
return replacer.replace( itemstack, user, pointed_thing, above );
|
|
end,
|
|
})
|