Let the Land Clear tools replacement block be selectable
This commit is contained in:
parent
a0257bfb22
commit
c64b6cd83b
@ -1,4 +1,4 @@
|
|||||||
local function process(itemstack, curr)
|
local function process(itemstack, curr, node)
|
||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
local last = meta:to_table().fields
|
local last = meta:to_table().fields
|
||||||
if last.x then
|
if last.x then
|
||||||
@ -11,7 +11,7 @@ local function process(itemstack, curr)
|
|||||||
for y = 0,ymax-ymin do
|
for y = 0,ymax-ymin do
|
||||||
for x = xmin,xmax do
|
for x = xmin,xmax do
|
||||||
for z = zmin,zmax do
|
for z = zmin,zmax do
|
||||||
minetest.set_node({x=x,y=ymax-y,z=z}, {name="air"})
|
minetest.set_node({x=x,y=ymax-y,z=z}, {name=node})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -22,6 +22,20 @@ local function process(itemstack, curr)
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_chatcommand("fillblock", {
|
||||||
|
desc = "Set the fill block for the Land Clear tool",
|
||||||
|
params = "nodestring",
|
||||||
|
func = function (name, param)
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if player then
|
||||||
|
player:set_attribute("sparkdebug_clearnode", param)
|
||||||
|
return true, "It is done."
|
||||||
|
else
|
||||||
|
return false, "Player not online."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_tool("sparkdebug:landclear", {
|
minetest.register_tool("sparkdebug:landclear", {
|
||||||
description = "Land Clear",
|
description = "Land Clear",
|
||||||
inventory_image = "landclear.png",
|
inventory_image = "landclear.png",
|
||||||
@ -29,11 +43,11 @@ minetest.register_tool("sparkdebug:landclear", {
|
|||||||
range = 50.0,
|
range = 50.0,
|
||||||
on_use = function(itemstack, player, pointed_thing)
|
on_use = function(itemstack, player, pointed_thing)
|
||||||
if pointed_thing["type"] == "node" then
|
if pointed_thing["type"] == "node" then
|
||||||
return process(itemstack, pointed_thing.under)
|
return process(itemstack, pointed_thing.under, player:get_attribute("sparkdebug_clearnode") or "air")
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
return process(itemstack, placer:get_pos())
|
return process(itemstack, placer:get_pos(), placer:get_attribute("sparkdebug_clearnode") or "air")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user