From 1b96953782e606d1e15ec10b69580ab98f19b026 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Thu, 7 Mar 2024 08:21:03 +0100 Subject: [PATCH] replacement disabling option --- place_tool.lua | 3 ++- readme.md | 2 ++ serialize.lua | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/place_tool.lua b/place_tool.lua index 2c55428..d5149d6 100644 --- a/place_tool.lua +++ b/place_tool.lua @@ -48,8 +48,9 @@ minetest.register_tool("pick_and_place:place", { notify_change(pos1, pos2) else -- placement + local disable_replacements = controls.zoom local schematic = meta:get_string("schematic") - local success, msg = pick_and_place.deserialize(pos1, schematic) + local success, msg = pick_and_place.deserialize(pos1, schematic, disable_replacements) if not success then minetest.chat_send_player(playername, "Placement error: " .. msg) else diff --git a/readme.md b/readme.md index 28eb5b0..e7670c5 100644 --- a/readme.md +++ b/readme.md @@ -50,6 +50,8 @@ If you pick-and-place a replacement node the default node-placement is replaced * The `param2` value is preserved and rotateable * A "group" can be specified to place the same randomized slot across the whole group and placement +**Note**: holding the "zoom" button on place disables the replacement engine + # Portability The placement tool can be shared across worlds if the nodes are available there. diff --git a/serialize.lua b/serialize.lua index 063ab40..fb9c682 100644 --- a/serialize.lua +++ b/serialize.lua @@ -54,7 +54,7 @@ function pick_and_place.serialize(pos1, pos2) end -function pick_and_place.deserialize(pos1, encoded_data) +function pick_and_place.deserialize(pos1, encoded_data, disable_replacements) local schematic, err = pick_and_place.decode_schematic(encoded_data) if err then return false, "Decode error: " .. err @@ -77,7 +77,7 @@ function pick_and_place.deserialize(pos1, encoded_data) local i = area:index(x,y,z) local nodeid = schematic.node_id_data[j] - if nodeid == replacement_cid then + if nodeid == replacement_cid and not disable_replacements then -- replacement placement local abs_pos = {x=x, y=y, z=z} local rel_pos = vector.subtract(abs_pos, pos1)