add admin replacer tool
This commit is contained in:
parent
46e0138f85
commit
9b6e44b7ad
53
replacer.lua
Normal file
53
replacer.lua
Normal 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,
|
||||
})
|
BIN
textures/replacer_replacer_admin.png
Normal file
BIN
textures/replacer_replacer_admin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 461 B |
Loading…
x
Reference in New Issue
Block a user