replacement disabling option

This commit is contained in:
BuckarooBanzay 2024-03-07 08:21:03 +01:00
parent 74ec1c2ade
commit 1b96953782
3 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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.

View File

@ -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)