mirror of
https://github.com/minetest-mods/ropes.git
synced 2024-11-28 02:13:43 +01:00
add optional extending ladders
This commit is contained in:
parent
73567f6b56
commit
a771d20a1b
@ -6,6 +6,8 @@ The rope stops lowering if it reaches an obstruction. Ropes can be cut using an
|
||||
|
||||
Also included is a rope ladder that behaves similarly, though it only comes in one standard maximum length - 50m by default, again changeable in settings.
|
||||
|
||||
Optionally, this mod can enhance default wood ladders and steel ladders to make them "extendable", capable of building upward independent of support to a setting-defined limit (defaulting to 5 nodes for wood and 15 nodes for steel ladders).
|
||||
|
||||
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.
|
5
doc.lua
5
doc.lua
@ -39,6 +39,11 @@ ropes.doc.ropebox_usage = rope_length_doc .. "\n\n" ..
|
||||
S("When a rope box is placed the rope will immediately begin lowering from it at one meter per second. The rope will only descend when its end is in the vicinity of an active player, suspending its journey when no players are nearby, so a long descent may require a player to climb down the rope as it goes. If you are near the bottom end of a rope that's extending you'll be automatically carried down with it. The rope will stop when it encounters and obstruction, but will resume lowering if the obstruction is removed.") .. "\n\n" ..
|
||||
S("A rope can be severed midway using an axe or other similar tool. The section of rope below the cut will collapse and disappear, potentially causing players who were hanging on to it to fall. The remaining rope will not resume descent on its own, but the rope box at the top of the rope \"remembers\" how long the rope was and if it is deconstructed and replaced it will still have the same maximum length of rope as before - no rope is permanently lost when a rope is severed like this.")
|
||||
|
||||
if ropes.extending_ladder_enabled then
|
||||
ropes.doc.ladder_longdesc = S("A ladder for climbing. It can reach greater heights when placed against a supporting block.")
|
||||
ropes.doc.ladder_usagehelp = S("Right-clicking on a ladder with a stack of identical ladder items will automatically add new ladder segments to the top, provided it hasn't extended too far up beyond the last block behind it providing support.")
|
||||
end
|
||||
|
||||
doc.add_entry_alias("nodes", "ropes:ropeladder_top", "nodes", "ropes:ropeladder")
|
||||
doc.add_entry_alias("nodes", "ropes:ropeladder_top", "nodes", "ropes:ropeladder_bottom")
|
||||
doc.add_entry_alias("nodes", "ropes:ropeladder_top", "nodes", "ropes:ropeladder_falling")
|
||||
|
178
extendingladder.lua
Normal file
178
extendingladder.lua
Normal file
@ -0,0 +1,178 @@
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(modpath.."/intllib.lua")
|
||||
|
||||
if ropes.extending_ladder_enabled then
|
||||
|
||||
minetest.unregister_item("default:ladder_wood")
|
||||
minetest.unregister_item("default:ladder_steel")
|
||||
minetest.clear_craft({output = "default:ladder_wood"})
|
||||
minetest.clear_craft({output = "default:ladder_steel"})
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "Switch from wallmounted default ladders to rope mod extending ladders",
|
||||
name = "ropes:wallmounted_ladder_to_facedir_ladder",
|
||||
nodenames = {"default:ladder_wood", "default:ladder_steel"},
|
||||
run_at_every_load = false,
|
||||
action = function(pos, node)
|
||||
local new_node = {param2=minetest.dir_to_facedir(minetest.wallmounted_to_dir(node.param2))}
|
||||
if (node.name == "default:ladder_wood") then
|
||||
new_node.name = "ropes:ladder_wood"
|
||||
else
|
||||
new_node.name = "ropes:ladder_steel"
|
||||
end
|
||||
minetest.set_node(pos, new_node)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "ropes:ladder_wood 5",
|
||||
recipe = {
|
||||
{"group:stick", "", "group:stick"},
|
||||
{"group:stick", "group:stick", "group:stick"},
|
||||
{"group:stick", "", "group:stick"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'ropes:ladder_steel 15',
|
||||
recipe = {
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
local ladder_extender = function(pos, node, clicker, itemstack, pointed_thing, ladder_node, standing_limit)
|
||||
local clicked_stack = ItemStack(itemstack)
|
||||
|
||||
-- true if we're pointing up at the ladder from below and there's a buildable space below it
|
||||
-- this check allows us to extend ladders downward
|
||||
local pointing_directly_below =
|
||||
pointed_thing.above.x == pos.x and
|
||||
pointed_thing.above.z == pos.z and
|
||||
pointed_thing.above.y == pos.y - 1 and
|
||||
minetest.registered_nodes[minetest.get_node(pointed_thing.above).name].buildable_to
|
||||
|
||||
if clicked_stack:get_name() == ladder_node and not pointing_directly_below then
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local dir = minetest.facedir_to_dir(param2)
|
||||
local scan_limit = pos.y + 6 -- Only add ladder segments up to five nodes above the one clicked on
|
||||
pos.y = pos.y + 1
|
||||
while pos.y < scan_limit and minetest.get_node(pos).name == ladder_node do
|
||||
param2 = minetest.get_node(pos).param2
|
||||
pos.y = pos.y + 1
|
||||
end
|
||||
if pos.y < scan_limit and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to then
|
||||
|
||||
-- scan downward behind the ladder to find support
|
||||
local behind_pos = vector.add(pos, minetest.facedir_to_dir(param2))
|
||||
local target_height = pos.y - standing_limit - 1
|
||||
while behind_pos.y > target_height and minetest.registered_nodes[minetest.get_node(behind_pos).name].buildable_to do
|
||||
behind_pos.y = behind_pos.y - 1
|
||||
end
|
||||
|
||||
-- If there's enough support, build a new ladder segment
|
||||
if behind_pos.y > target_height then
|
||||
if minetest.is_protected(pos, clicker:get_player_name()) then
|
||||
minetest.record_protection_violation(clicker:get_player_name())
|
||||
else
|
||||
minetest.set_node(pos, {name=ladder_node, param2=param2})
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
clicked_stack:take_item(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif clicked_stack:get_definition().type == "node" then
|
||||
return minetest.item_place_node(itemstack, clicker, pointed_thing)
|
||||
end
|
||||
return clicked_stack
|
||||
end
|
||||
|
||||
minetest.register_node("ropes:ladder_wood", {
|
||||
description = S("Wooden Ladder"),
|
||||
_doc_items_longdesc = ropes.doc.ladder_longdesc,
|
||||
_doc_items_usagehelp = ropes.doc.ladder_usagehelp,
|
||||
drawtype = "signlike",
|
||||
tiles = {"default_wood.png","default_wood.png","default_wood.png^[transformR270","default_wood.png^[transformR270","ropes_ladder_wood.png"},
|
||||
inventory_image = "ropes_ladder_wood.png",
|
||||
wield_image = "ropes_ladder_wood.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
is_ground_content = false,
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.375, -0.5, 0.3125, -0.1875, 0.5, 0.5}, -- Upright1
|
||||
{0.1875, -0.5, 0.3125, 0.375, 0.5, 0.5}, -- Upright2
|
||||
{-0.4375, 0.3125, 0.375, 0.4375, 0.4375, 0.5}, -- Rung_4
|
||||
{-0.4375, -0.1875, 0.375, 0.4375, -0.0625, 0.5}, -- Rung_2
|
||||
{-0.4375, -0.4375, 0.375, 0.4375, -0.3125, 0.5}, -- Rung_1
|
||||
{-0.4375, 0.0625, 0.375, 0.4375, 0.1875, 0.5}, -- Rung_3
|
||||
}
|
||||
},
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 3, flammable = 2, flow_through = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return ladder_extender(pos, node, clicker, itemstack, pointed_thing, "ropes:ladder_wood", ropes.extending_wood_ladder_limit)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("ropes:ladder_steel", {
|
||||
description = S("Steel Ladder"),
|
||||
_doc_items_longdesc = ropes.doc.ladder_longdesc,
|
||||
_doc_items_usagehelp = ropes.doc.ladder_usagehelp,
|
||||
drawtype = "signlike",
|
||||
tiles = {"default_steel_block.png","default_steel_block.png","default_steel_block.png","default_steel_block.png","ropes_ladder_steel.png"},
|
||||
inventory_image = "ropes_ladder_steel.png",
|
||||
wield_image = "ropes_ladder_steel.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
is_ground_content = false,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.4375, -0.5, 0.3125, -0.25, 0.5, 0.5}, -- Upright1
|
||||
{0.25, -0.5, 0.3125, 0.4375, 0.5, 0.5}, -- Upright2
|
||||
{-0.25, 0.3125, 0.375, 0.25, 0.4375, 0.5}, -- Rung_4
|
||||
{-0.25, -0.1875, 0.375, 0.25, -0.0625, 0.5}, -- Rung_2
|
||||
{-0.25, -0.4375, 0.375, 0.25, -0.3125, 0.5}, -- Rung_1
|
||||
{-0.25, 0.0625, 0.375, 0.25, 0.1875, 0.5}, -- Rung_3
|
||||
}
|
||||
},
|
||||
groups = {cracky = 2, flow_through = 1},
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return ladder_extender(pos, node, clicker, itemstack, pointed_thing, "ropes:ladder_steel", ropes.extending_steel_ladder_limit)
|
||||
end,
|
||||
})
|
||||
|
||||
else
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "Switch from ropes ladders to wallmounted default ladders",
|
||||
name = "ropes:facedir_ladder_to_wallmounted_ladder",
|
||||
nodenames = {"ropes:ladder_wood", "ropes:ladder_steel"},
|
||||
run_at_every_load = false,
|
||||
action = function(pos, node)
|
||||
local new_node = {param2=minetest.dir_to_wallmounted(minetest.facedir_to_dir(node.param2))}
|
||||
if (node.name == "ropes:ladder_wood") then
|
||||
new_node.name = "default:ladder_wood"
|
||||
else
|
||||
new_node.name = "default:ladder_steel"
|
||||
end
|
||||
minetest.set_node(pos, new_node)
|
||||
end,
|
||||
})
|
||||
|
||||
end
|
18
init.lua
18
init.lua
@ -12,13 +12,17 @@ ropes.woodRopeBoxMaxMultiple = tonumber(minetest.settings:get("ropes_wood_rope_b
|
||||
ropes.copperRopeBoxMaxMultiple = tonumber(minetest.settings:get("ropes_copper_rope_box_max_multiple")) or 5
|
||||
ropes.steelRopeBoxMaxMultiple = tonumber(minetest.settings:get("ropes_steel_rope_box_max_multiple")) or 9
|
||||
ropes.create_all_definitions = minetest.settings:get_bool("ropes_create_all_definitions")
|
||||
ropes.extending_ladder_enabled = minetest.settings:get_bool("ropes_extending_ladder_enabled")
|
||||
ropes.extending_wood_ladder_limit = tonumber(minetest.settings:get("ropes_extending_wood_ladder_limit")) or 5
|
||||
ropes.extending_steel_ladder_limit = tonumber(minetest.settings:get("ropes_extending_steel_ladder_limit")) or 15
|
||||
|
||||
dofile( minetest.get_modpath( ropes.name ) .. "/doc.lua" )
|
||||
dofile( minetest.get_modpath( ropes.name ) .. "/functions.lua" )
|
||||
dofile( minetest.get_modpath( ropes.name ) .. "/crafts.lua" )
|
||||
dofile( minetest.get_modpath( ropes.name ) .. "/ropeboxes.lua" )
|
||||
dofile( minetest.get_modpath( ropes.name ) .. "/ladder.lua" )
|
||||
dofile( minetest.get_modpath( ropes.name ) .. "/loot.lua" )
|
||||
dofile( MP .. "/doc.lua" )
|
||||
dofile( MP .. "/functions.lua" )
|
||||
dofile( MP .. "/crafts.lua" )
|
||||
dofile( MP .. "/ropeboxes.lua" )
|
||||
dofile( MP .. "/ropeladder.lua" )
|
||||
dofile( MP .. "/extendingladder.lua" )
|
||||
dofile( MP .. "/loot.lua" )
|
||||
|
||||
|
||||
for i=1,5 do
|
||||
@ -40,4 +44,4 @@ minetest.register_alias("castle:ropes", "ropes:rope")
|
||||
minetest.register_alias("castle:ropebox", "ropes:steel1rope_block")
|
||||
minetest.register_alias("castle:box_rope", "ropes:rope")
|
||||
|
||||
print(S("[Ropes] Loaded!"))
|
||||
print("[Ropes] Loaded!")
|
||||
|
@ -8,15 +8,16 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-02-09 21:21-0700\n"
|
||||
"POT-Creation-Date: 2018-11-27 01:00-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: crafts.lua:17
|
||||
#: crafts.lua:54
|
||||
msgid "Rope Segment"
|
||||
msgstr ""
|
||||
|
||||
@ -58,23 +59,33 @@ msgid ""
|
||||
"box in the crafting grid by itself."
|
||||
msgstr ""
|
||||
|
||||
#: doc.lua:20 doc.lua:22 ropeboxes.lua:302
|
||||
#: doc.lua:20
|
||||
#: doc.lua:22
|
||||
#: ropeboxes.lua:321
|
||||
msgid "Wood"
|
||||
msgstr ""
|
||||
|
||||
#: doc.lua:20 doc.lua:26 doc.lua:32
|
||||
#: doc.lua:20
|
||||
#: doc.lua:26
|
||||
#: doc.lua:32
|
||||
msgid "rope boxes can hold @1m of rope."
|
||||
msgstr ""
|
||||
|
||||
#: doc.lua:22 doc.lua:28 doc.lua:34
|
||||
#: doc.lua:22
|
||||
#: doc.lua:28
|
||||
#: doc.lua:34
|
||||
msgid "rope boxes can hold rope lengths from @1m to @2m."
|
||||
msgstr ""
|
||||
|
||||
#: doc.lua:26 doc.lua:28 ropeboxes.lua:319
|
||||
#: doc.lua:26
|
||||
#: doc.lua:28
|
||||
#: ropeboxes.lua:338
|
||||
msgid "Copper"
|
||||
msgstr ""
|
||||
|
||||
#: doc.lua:32 doc.lua:34 ropeboxes.lua:336
|
||||
#: doc.lua:32
|
||||
#: doc.lua:34
|
||||
#: ropeboxes.lua:355
|
||||
msgid "Steel"
|
||||
msgstr ""
|
||||
|
||||
@ -106,18 +117,39 @@ msgid ""
|
||||
"permanently lost when a rope is severed like this."
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:72
|
||||
msgid "[Ropes] Loaded!"
|
||||
#: doc.lua:43
|
||||
msgid ""
|
||||
"A ladder for climbing. It can reach greater heights when placed against a "
|
||||
"supporting block."
|
||||
msgstr ""
|
||||
|
||||
#: ladder.lua:27 ladder.lua:78 ladder.lua:108 ladder.lua:142
|
||||
msgid "Rope Ladder"
|
||||
#: doc.lua:44
|
||||
msgid ""
|
||||
"Right-clicking on a ladder with a stack of identical ladder items will "
|
||||
"automatically add new ladder segments to the top, provided it hasn't "
|
||||
"extended too far up beyond the last block behind it providing support."
|
||||
msgstr ""
|
||||
|
||||
#: extendingladder.lua:94
|
||||
msgid "Wooden Ladder"
|
||||
msgstr ""
|
||||
|
||||
#: extendingladder.lua:128
|
||||
msgid "Steel Ladder"
|
||||
msgstr ""
|
||||
|
||||
#: ropeboxes.lua:121
|
||||
msgid "@1 Ropebox @2m"
|
||||
msgstr ""
|
||||
|
||||
#: ropeboxes.lua:218 ropeboxes.lua:249
|
||||
#: ropeboxes.lua:229
|
||||
#: ropeboxes.lua:264
|
||||
msgid "Rope"
|
||||
msgstr ""
|
||||
|
||||
#: ropeladder.lua:27
|
||||
#: ropeladder.lua:89
|
||||
#: ropeladder.lua:119
|
||||
#: ropeladder.lua:153
|
||||
msgid "Rope Ladder"
|
||||
msgstr ""
|
||||
|
6
locale/update.bat
Normal file
6
locale/update.bat
Normal file
@ -0,0 +1,6 @@
|
||||
@echo off
|
||||
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
|
||||
cd ..
|
||||
set LIST=
|
||||
for /r %%X in (*.lua) do set LIST=!LIST! %%X
|
||||
..\intllib\tools\xgettext.bat %LIST%
|
@ -34,4 +34,13 @@ ropes_steel_rope_box_max_multiple (Maximum steel rope box multiple) int 9 0 9
|
||||
#intended for the situation where you have an established world and you want
|
||||
#to reduce the number of rope boxes available to players without turning
|
||||
#existing rope boxes into "unknown node"s.
|
||||
ropes_create_all_definitions (Create all rope box definitions) bool false
|
||||
ropes_create_all_definitions (Create all rope box definitions) bool false
|
||||
|
||||
#Extending ladders replaces the default wallmounted wood and steel ladders
|
||||
#with ladders capable of standing on their own, to a defined limit.
|
||||
#A ladder can extend to its unsupported limit before needing another node
|
||||
#behind it to provide a new point of support. Right-clicking on an existing
|
||||
#ladder with a stack of ladders will add new ladder segments to its top.
|
||||
ropes_extending_ladder_enabled (Enable extendable ladders) bool false
|
||||
ropes_extending_wood_ladder_limit (Unsupported limit of wooden ladders) int 5
|
||||
ropes_extending_steel_ladder_limit (Unsupported limit of steel ladders) int 15
|
BIN
textures/ropes_ladder_steel.png
Normal file
BIN
textures/ropes_ladder_steel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 533 B |
BIN
textures/ropes_ladder_wood.png
Normal file
BIN
textures/ropes_ladder_wood.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 525 B |
Loading…
Reference in New Issue
Block a user