diff --git a/README.md b/README.md index c914484..b46d7c7 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ Maintenance updates: * Add description to every setting * Add tooltip extensions for some interactive items (uses `tt` mod) * Add crafting guide support for `unified_inventory` mod (honey) +* Rope no longer extends infinitely in Creative Mode #### List of replaced files diff --git a/src/rope.lua b/src/rope.lua index 7e8c26f..18320de 100644 --- a/src/rope.lua +++ b/src/rope.lua @@ -23,10 +23,13 @@ function rope.place(itemstack, placer, pointed_thing) local oldnode = minetest.get_node(pos) local stackname = itemstack:get_name() + -- Limit max. rope length to max. stack size + -- Prevents the rope to extend infinitely in Creative Mode + local max_ropes = itemstack:get_stack_max() local start_pos = table.copy(pos) - local ropes_placed = false - while oldnode.name == "air" and not itemstack:is_empty() do + local ropes_placed = 0 + while oldnode.name == "air" and not itemstack:is_empty() and ropes_placed < max_ropes do local newnode = {name = stackname, param1 = 0} minetest.set_node(pos, newnode) if not minetest.is_creative_enabled(placer:get_player_name()) then @@ -34,9 +37,10 @@ function rope.place(itemstack, placer, pointed_thing) end pos.y = pos.y - 1 oldnode = minetest.get_node(pos) + ropes_placed = ropes_placed + 1 end -- Play placement sound manually - if rope_placed then + if ropes_placed > 0 then minetest.sound_play(ropesounds.place, {pos=start_pos}, true) end end