include admin replacer - should become a cross-server-mod

master
Milan 2021-01-23 16:01:42 +01:00
parent e37f0071fa
commit 09de19ca95
3 changed files with 54 additions and 0 deletions

View File

@ -10,3 +10,4 @@ dofile(path .. "/hotstone.lua")
dofile(path .. "/register.lua")
dofile(path .. "/bonemeal.lua")
dofile(path .. "/signs.lua")
dofile(path .. "/replacer.lua")

View File

@ -0,0 +1,53 @@
-- 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,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B