From c64b6cd83bc63b50cbf943a755e6449ae61801e4 Mon Sep 17 00:00:00 2001 From: Valentin Anger Date: Fri, 21 Sep 2018 13:20:24 +0200 Subject: [PATCH] Let the Land Clear tools replacement block be selectable --- sparkdebug/landclear.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/sparkdebug/landclear.lua b/sparkdebug/landclear.lua index 38aa4cf..b1bab6a 100644 --- a/sparkdebug/landclear.lua +++ b/sparkdebug/landclear.lua @@ -1,4 +1,4 @@ -local function process(itemstack, curr) +local function process(itemstack, curr, node) local meta = itemstack:get_meta() local last = meta:to_table().fields if last.x then @@ -11,7 +11,7 @@ local function process(itemstack, curr) for y = 0,ymax-ymin do for x = xmin,xmax 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 @@ -22,6 +22,20 @@ local function process(itemstack, curr) return itemstack 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", { description = "Land Clear", inventory_image = "landclear.png", @@ -29,11 +43,11 @@ minetest.register_tool("sparkdebug:landclear", { range = 50.0, on_use = function(itemstack, player, pointed_thing) 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 return itemstack end, 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 })