mirror of
https://github.com/minetest-mods/ropes.git
synced 2024-11-24 08:23:47 +01:00
Add options to allow ropes to extend into nodes other than "air"
This commit is contained in:
parent
74c05e2243
commit
69730118d9
@ -11,3 +11,7 @@ This mod will also enhance default wood ladders and steel ladders to make them "
|
||||
This mod retains optional backward compatibility with the crafting items from the vines mod (anything with group "vines" can be used to make rope boxes and rope ladders). Ropes can also be made from cotton, available via an optional dependency on the farming mod.
|
||||
|
||||
In-game documentation is provided via an optional dependency on the doc mod.
|
||||
|
||||
## Interaction with other mods
|
||||
|
||||
By default ropes and rope ladders only extend downward into "air" nodes. Other mods can modify this behaviour to add other nodes as valid targets for ropes to extend into using either of two mechanisms: either add `ropes_can_extend_into = 1` to the node definition's groups list or add a dependency on the ropes mod to your mod and then set `ropes.can_extend_into_nodes[target_node_name] = true`. There is also a configuration setting, `ropes_can_extend_into_airlike`, that will allow ropes to extend into any node with `drawtype = "airlike"` in its definition. Note that in cases where ropes extend into non-air nodes the rope will still be replaced with an "air" node when it's eventually destroyed.
|
@ -1,3 +1,19 @@
|
||||
ropes.can_place_rope_in_node = function(target_node_name)
|
||||
if ropes.can_extend_into_nodes[target_node_name] == true then
|
||||
return true
|
||||
end
|
||||
local target_def = minetest.registered_nodes[target_node_name]
|
||||
if target_def then
|
||||
if target_def.drawtype == "airlike" and ropes.can_extend_into_airlike then
|
||||
return true
|
||||
end
|
||||
if target_def.groups and target_def.groups.ropes_can_extend_into then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
ropes.make_rope_on_timer = function(rope_node_name)
|
||||
return function(pos, elapsed)
|
||||
local currentend = minetest.get_node(pos)
|
||||
@ -9,7 +25,7 @@ ropes.make_rope_on_timer = function(rope_node_name)
|
||||
local oldnode = minetest.get_node(pos)
|
||||
if currentlength > 1 and (not minetest.is_protected(newpos, placer_name)
|
||||
or minetest.check_player_privs(placer_name, "protection_bypass")) then
|
||||
if newnode.name == "air" then
|
||||
if ropes.can_place_rope_in_node(newnode.name) then
|
||||
minetest.add_node(newpos, {name=currentend.name, param2=oldnode.param2})
|
||||
local newmeta = minetest.get_meta(newpos)
|
||||
newmeta:set_int("length_remaining", currentlength-1)
|
||||
|
6
init.lua
6
init.lua
@ -28,6 +28,12 @@ if ropes.bridges_enabled == nil then
|
||||
ropes.bridges_enabled = true
|
||||
end
|
||||
|
||||
ropes.can_extend_into_airlike = minetest.settings:get_bool("ropes_can_extend_into_airlike")
|
||||
ropes.can_extend_into_nodes = {["air"] = true}
|
||||
if minetest.get_modpath("nether") then
|
||||
ropes.can_extend_into_nodes["nether:fumes"] = true
|
||||
end
|
||||
|
||||
dofile( MP .. "/doc.lua" )
|
||||
dofile( MP .. "/functions.lua" )
|
||||
dofile( MP .. "/crafts.lua" )
|
||||
|
@ -155,7 +155,7 @@ local function register_rope_block(multiple, max_multiple, name_prefix, node_pre
|
||||
end
|
||||
|
||||
local node_below = minetest.get_node(pos_below)
|
||||
if node_below.name == "air" then
|
||||
if ropes.can_place_rope_in_node(node_below.name) then
|
||||
minetest.add_node(pos_below, {name="ropes:rope_bottom"})
|
||||
local meta = minetest.get_meta(pos_below)
|
||||
meta:set_int("length_remaining", ropes.ropeLength*multiple)
|
||||
|
@ -64,7 +64,7 @@ local rope_ladder_top_def = {
|
||||
local this_node = minetest.get_node(pos)
|
||||
local placer_name = placer:get_player_name()
|
||||
-- param2 holds the facing direction of this node. If it's 0 or 1 the node is "flat" and we don't want the ladder to extend.
|
||||
if node_below.name == "air" and this_node.param2 > 1
|
||||
if ropes.can_place_rope_in_node(node_below.name) and this_node.param2 > 1
|
||||
and (not minetest.is_protected(pos_below, placer_name)
|
||||
or minetest.check_player_privs(placer_name, "protection_bypass")) then
|
||||
minetest.add_node(pos_below, {name="ropes:ropeladder_bottom", param2=this_node.param2})
|
||||
|
@ -52,3 +52,7 @@ ropes_extending_steel_ladder_limit (Unsupported limit of steel ladders) int 15
|
||||
#These nodes make it easier to build bridges by extending out away
|
||||
#from the player as they're placed
|
||||
ropes_bridges_enabled (Enable bridges) bool true
|
||||
|
||||
#Allows ropes and rope ladders to extend into all "airlike" nodes.
|
||||
#Note that ropes will leave "air" nodes behind when destroyed.
|
||||
ropes_can_extend_into_airlike (Ropes can extend into all nodes with drawtype airlike) bool false
|
Loading…
Reference in New Issue
Block a user