improve ladders, add bridges

This commit is contained in:
FaceDeer 2018-11-27 23:07:01 -07:00
parent 168891c3e7
commit 9dac0858d7
10 changed files with 194 additions and 28 deletions

View File

@ -6,7 +6,7 @@ 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 will also 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 can be disabled if undesired.
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.

88
bridge.lua Normal file
View File

@ -0,0 +1,88 @@
local modpath = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(modpath.."/intllib.lua")
if ropes.bridges_enabled then
local bridge_on_place = function(itemstack, placer, pointed_thing)
-- Shall place item and return the leftover itemstack.
-- The placer may be any ObjectRef or nil.
-- default: minetest.item_place
if placer == nil then
return minetest.item_place(itemstack, placer, pointed_thing)
end
local above = pointed_thing.above
local under = pointed_thing.under
if above.x == under.x and above.z == under.z and above.y > under.y then
-- we're aimed downward at a buildable node from above.
-- determine the direction the placer lies relative to this node.
local new_under = vector.new(under)
local placer_pos = placer:get_pos()
local diff_x = placer_pos.x - under.x
local diff_z = placer_pos.z - under.z
if math.abs(diff_x) > math.abs(diff_z) then
-- placer is displaced along the X axis relative to the target
if diff_x > 0 then
new_under.x = under.x - 1
else
new_under.x = under.x + 1
end
else
-- placer is displaced along the Z axis relative to the target
if diff_z > 0 then
new_under.z = under.z - 1
else
new_under.z = under.z + 1
end
end
if minetest.registered_nodes[minetest.get_node(new_under).name].buildable_to then
local new_pointed_thing = {type="node", under=new_under, above={x=new_under.x, y=new_under.y+1, z=new_under.z}}
return minetest.item_place(itemstack, placer, new_pointed_thing)
end
end
return minetest.item_place(itemstack, placer, pointed_thing)
end
minetest.register_node("ropes:wood_bridge", {
description = S("Wooden Bridge"),
_doc_items_longdesc = ropes.doc.wooden_bridge_longdesc,
_doc_items_usagehelp = ropes.doc.wooden_bridge_usagehelp,
tiles = {
"default_wood.png", "default_wood.png",
"default_wood.png^[transformR270", "default_wood.png^[transformR90",
"default_wood.png^[transformR270", "default_wood.png^[transformR90",
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {choppy = 2, flammable = 2, oddly_breakable_by_hand = 1, flow_through = 1, fence = 1, wall = 1},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.5, 0.375, -0.5, 0.5, 0.5, 0.5}, -- Platform
{-0.375, -0.5, -0.5, 0.375, -0.375, -0.4375}, -- x beam4
{-0.375, -0.5, 0.4375, 0.375, -0.375, 0.5}, -- x beam3
{0.375, -0.5, -0.4375, 0.5, -0.375, 0.4375}, -- z beam2
{-0.5, -0.5, -0.4375, -0.375, -0.375, 0.4375}, -- z beam1
{0.375, -0.5, -0.5, 0.5, 0.375, -0.4375}, -- upright4
{0.375, -0.5, 0.4375, 0.5, 0.375, 0.5}, -- upright3
{-0.5, -0.5, -0.5, -0.375, 0.375, -0.4375}, -- upright2
{-0.5, -0.5, 0.4375, -0.375, 0.375, 0.5}, -- upright1
}
},
on_place = bridge_on_place,
})
minetest.register_craft({
output = "ropes:wood_bridge 5",
recipe = {
{"group:stick", "stairs:slab_wood", "group:stick"},
{"group:stick", "", "group:stick"},
{"group:stick", "group:stick", "group:stick"},
}
})
end

View File

@ -44,6 +44,9 @@ if ropes.extending_ladder_enabled then
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
ropes.doc.wooden_bridge_longdesc = S("A wooden platform with support struts useful for bridging gaps.")
ropes.doc.wooden_bridge_usagehelp = S("This behaves like most structural blocks except in one circumstance: when placed on top of a block with buildable space on the side facing away from you, this block will not be built on top but instead will extend out from that far side of the target block. This allows a platform to be easily built that juts out away from the location you're standing on.")
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")

View File

@ -8,13 +8,22 @@ minetest.unregister_item("default:ladder_steel")
minetest.clear_craft({output = "default:ladder_wood"})
minetest.clear_craft({output = "default:ladder_steel"})
local wallmounted_to_facedir =
{[0] = 15, -- ceiling
[1] = 13, -- floor
[2] = 1, -- +X
[3] = 3, -- -X
[4] = 0, -- +Z
[5] = 2, -- -Z
}
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))}
local new_node = {param2 = wallmounted_to_facedir[node.param2]}
if (node.name == "default:ladder_wood") then
new_node.name = "ropes:ladder_wood"
else
@ -94,10 +103,9 @@ 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",
tiles = {"default_wood.png","default_wood.png","default_wood.png^[transformR270","default_wood.png^[transformR270","default_ladder_wood.png"},
inventory_image = "default_ladder_wood.png",
wield_image = "default_ladder_wood.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
@ -109,12 +117,12 @@ minetest.register_node("ropes:ladder_wood", {
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
{-0.375, -0.5, 0.375, -0.25, 0.5, 0.5}, -- Upright1
{0.25, -0.5, 0.375, 0.375, 0.5, 0.5}, -- Upright2
{-0.4375, 0.3125, 0.4375, 0.4375, 0.4375, 0.5}, -- Rung_4
{-0.4375, -0.1875, 0.4375, 0.4375, -0.0625, 0.5}, -- Rung_2
{-0.4375, -0.4375, 0.4375, 0.4375, -0.3125, 0.5}, -- Rung_1
{-0.4375, 0.0625, 0.4375, 0.4375, 0.1875, 0.5}, -- Rung_3
}
},
groups = {choppy = 2, oddly_breakable_by_hand = 3, flammable = 2, flow_through = 1},
@ -128,10 +136,9 @@ 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",
tiles = {"default_steel_block.png","default_steel_block.png","default_steel_block.png","default_steel_block.png","default_ladder_steel.png"},
inventory_image = "default_ladder_steel.png",
wield_image = "default_ladder_steel.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
@ -159,13 +166,32 @@ minetest.register_node("ropes:ladder_steel", {
else
-- Table of possible wallmounted values
local facedir_to_wallmounted = {
4, -- +Z
2, -- +X
5, -- -Z
3, -- -X
1, -- -Y
0, -- +Y
}
-- Mapping from facedir value to index in facedir_to_dir.
local facedir_to_wallmounted_map = {
[0]=1, 2, 3, 4,
5, 2, 6, 4,
6, 2, 5, 4,
1, 5, 3, 6,
1, 6, 3, 5,
1, 4, 3, 2,
}
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))}
local new_node = {param2 = facedir_to_wallmounted[facedir_to_wallmounted_map[node.param2 % 32]]}
if (node.name == "ropes:ladder_wood") then
new_node.name = "default:ladder_wood"
else

View File

@ -7,21 +7,32 @@ local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
ropes.ropeLength = tonumber(minetest.settings:get("ropes_rope_length")) or 50
ropes.ropeLadderLength = tonumber(minetest.settings:get("ropes_rope_ladder_length")) or 50
ropes.woodRopeBoxMaxMultiple = tonumber(minetest.settings:get("ropes_wood_rope_box_max_multiple")) or 2
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.ropeLadderLength = tonumber(minetest.settings:get("ropes_rope_ladder_length")) or 50
ropes.extending_ladder_enabled = minetest.settings:get_bool("ropes_extending_ladder_enabled")
if ropes.extending_ladder_enabled == nil then
ropes.extending_ladder_enabled = true
end
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
ropes.bridges_enabled = minetest.settings:get_bool("ropes_bridges_enabled")
if ropes.bridges_enabled == nil then
ropes.bridges_enabled = true
end
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 .. "/bridge.lua" )
dofile( MP .. "/loot.lua" )

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-27 01:21-0700\n"
"POT-Creation-Date: 2018-11-27 22:45-0700\n"
"PO-Revision-Date: 2018-10-27 11:26+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -18,6 +18,10 @@ msgstr ""
"X-Generator: Poedit 1.8.11\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: bridge.lua:47
msgid "Wooden Bridge"
msgstr ""
#: crafts.lua:54
msgid "Rope Segment"
msgstr "Segmento de cuerda"
@ -172,11 +176,24 @@ msgid ""
"extended too far up beyond the last block behind it providing support."
msgstr ""
#: extendingladder.lua:94
#: doc.lua:47
msgid "A wooden platform with support struts useful for bridging gaps."
msgstr ""
#: doc.lua:48
msgid ""
"This behaves like most structural blocks except in one circumstance: when "
"placed on top of a block with buildable space on the side facing away from "
"you, this block will not be built on top but instead will extend out from "
"that far side of the target block. This allows a platform to be easily built "
"that juts out away from the location you're standing on."
msgstr ""
#: extendingladder.lua:103
msgid "Wooden Ladder"
msgstr ""
#: extendingladder.lua:128
#: extendingladder.lua:136
msgid "Steel Ladder"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-27 01:00-0700\n"
"POT-Creation-Date: 2018-11-27 22:45-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"
@ -17,6 +17,10 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: bridge.lua:47
msgid "Wooden Bridge"
msgstr ""
#: crafts.lua:54
msgid "Rope Segment"
msgstr ""
@ -130,11 +134,24 @@ msgid ""
"extended too far up beyond the last block behind it providing support."
msgstr ""
#: extendingladder.lua:94
#: doc.lua:47
msgid "A wooden platform with support struts useful for bridging gaps."
msgstr ""
#: doc.lua:48
msgid ""
"This behaves like most structural blocks except in one circumstance: when "
"placed on top of a block with buildable space on the side facing away from "
"you, this block will not be built on top but instead will extend out from "
"that far side of the target block. This allows a platform to be easily built "
"that juts out away from the location you're standing on."
msgstr ""
#: extendingladder.lua:103
msgid "Wooden Ladder"
msgstr ""
#: extendingladder.lua:128
#: extendingladder.lua:136
msgid "Steel Ladder"
msgstr ""

View File

@ -41,6 +41,10 @@ ropes_create_all_definitions (Create all rope box definitions) bool false
#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_ladder_enabled (Enable extendable ladders) bool true
ropes_extending_wood_ladder_limit (Unsupported limit of wooden ladders) int 5
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B