From 78b4844c4cc8cdefee4ed243648cc58e369c76b1 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Mon, 30 Jan 2017 11:30:53 -0700 Subject: [PATCH] Add rope documentation via an optional dependency on the doc mod Haven't done vines yet, will likely do that after splitting the mod in two --- crafts.lua | 2 ++ depends.txt | 1 + doc.lua | 25 +++++++++++++++++++++++++ init.lua | 1 + ladder.lua | 5 +++++ ropeboxes.lua | 9 +++++++++ 6 files changed, 43 insertions(+) create mode 100644 doc.lua diff --git a/crafts.lua b/crafts.lua index fa379b1..9f1c133 100644 --- a/crafts.lua +++ b/crafts.lua @@ -11,6 +11,8 @@ minetest.register_craft({ minetest.register_craftitem("vines:ropesegment", { description = "Rope", + _doc_items_longdesc = vines.doc.ropesegment_longdesc, + _doc_items_usagehelp = vines.doc.ropesegment_usage, groups = {vines = 1}, inventory_image = "vines_item.png", }) diff --git a/depends.txt b/depends.txt index 573e6e1..7b62beb 100644 --- a/depends.txt +++ b/depends.txt @@ -1,3 +1,4 @@ default biome_lib moretrees? +doc? \ No newline at end of file diff --git a/doc.lua b/doc.lua new file mode 100644 index 0000000..fb7fa10 --- /dev/null +++ b/doc.lua @@ -0,0 +1,25 @@ +vines.doc = {} + +if not minetest.get_modpath("doc") then + return +end + +vines.doc.ropesegment_longdesc = "Rope segments are bundles of fibre twisted into robust cables." +vines.doc.ropesegment_usage = "This craft item is useful for creating rope ladders, or for spooling on wooden spindles to hang and climb upon." + +vines.doc.ropeladder_longdesc = "A hanging rope ladder that automatically extends downward" +vines.doc.ropeladder_usage = "After a rope ladder is placed on a vertical wall it will begin extending downward until it reaches its maximum length (" .. tostring(vines.ropeLadderLength) .. "m). If the rope ladder is removed all of the ladder below the point of removal will disappear. A rope ladder can be severed partway down using an axe or similar tool, and the ladder below the point where it is cut will collapse. No rope is actually lost in the process, though, and if the uppermost section of the ladder is removed and replaced the ladder will re-extend to the same maximum length as before." + +vines.doc.ropebox_longdesc = "Ropes are hung by placing rope boxes, which automatically lower a rope of fixed length below them. They can be climbed and cut." +vines.doc.ropebox_usage = "Rope boxes have a certain amount of rope contained within them specified in the name of the node. They come in five standard lengths " .. + string.format("(%dm, %dm, %dm, %dm and %dm)", vines.ropeLength, vines.ropeLength*2, vines.ropeLength*3, vines.ropeLength*4, vines.ropeLength*5) .. + " that can be crafted by combining and splitting up rope boxes in the crafting grid. For example, you can craft a " .. tostring(vines.ropeLength*2) .. "m rope box by combining two " .. tostring(vines.ropeLength) .. "m rope boxes, and the two " .. tostring(vines.ropeLength) .. "m rope boxes can be recovered by splitting it back up in the crafting grid.\n\n" .. + "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. Take care not to fall off the end! The rope will stop when it encounters and obstruction, but will resume lowering if the obstruction is removed.\n\n" .. + "A rope can be severed midway using an axe or other similar tools. 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 permnanently lost when a rope is severed like this." + +doc.add_entry_alias("nodes", "vines:ropeladder_top", "nodes", "vines:ropeladder") +doc.add_entry_alias("nodes", "vines:ropeladder_top", "nodes", "vines:ropeladder_bottom") +doc.add_entry_alias("nodes", "vines:ropeladder_top", "nodes", "vines:ropeladder_falling") + +doc.add_entry_alias("nodes", "vines:rope", "nodes", "vines:rope_bottom") +doc.add_entry_alias("nodes", "vines:rope", "nodes", "vines:rope_top") \ No newline at end of file diff --git a/init.lua b/init.lua index e5a7a4c..5fefc4b 100644 --- a/init.lua +++ b/init.lua @@ -14,6 +14,7 @@ if not rope_ladder_length then end vines.ropeLadderLength = rope_ladder_length +dofile( minetest.get_modpath( vines.name ) .. "/doc.lua" ) dofile( minetest.get_modpath( vines.name ) .. "/functions.lua" ) dofile( minetest.get_modpath( vines.name ) .. "/aliases.lua" ) dofile( minetest.get_modpath( vines.name ) .. "/crafts.lua" ) diff --git a/ladder.lua b/ladder.lua index e127652..f00bbbe 100644 --- a/ladder.lua +++ b/ladder.lua @@ -1,5 +1,7 @@ minetest.register_node("vines:ropeladder_top", { description = "Rope ladder", + _doc_items_longdesc = vines.doc.ropeladder_longdesc, + _doc_items_usagehelp = vines.doc.ropeladder_usage, drawtype = "signlike", tiles = {"default_ladder_wood.png^vines_ropeladder_top.png"}, is_ground_content = false, @@ -47,6 +49,7 @@ minetest.register_craft({ minetest.register_node("vines:ropeladder", { description = "Rope ladder", + _doc_items_create_entry = false, drop = "", drawtype = "signlike", tiles = {"default_ladder_wood.png^vines_ropeladder.png"}, @@ -74,6 +77,7 @@ minetest.register_node("vines:ropeladder", { minetest.register_node("vines:ropeladder_bottom", { description = "Rope ladder", + _doc_items_create_entry = false, drop = "", drawtype = "signlike", tiles = {"default_ladder_wood.png^vines_ropeladder_bottom.png"}, @@ -125,6 +129,7 @@ minetest.register_node("vines:ropeladder_bottom", { minetest.register_node("vines:ropeladder_falling", { description = "Rope ladder", + _doc_items_create_entry = false, drop = "", drawtype = "signlike", tiles = {"default_ladder_wood.png^vines_ropeladder.png"}, diff --git a/ropeboxes.lua b/ropeboxes.lua index b976201..ae337ec 100644 --- a/ropeboxes.lua +++ b/ropeboxes.lua @@ -1,6 +1,7 @@ local function register_rope_block(multiple, pixels) minetest.register_node(string.format("vines:%irope_block", multiple), { description = string.format("Rope %im", vines.ropeLength*multiple), + _doc_items_create_entry = false, drawtype="nodebox", sunlight_propagates = true, paramtype = "light", @@ -71,6 +72,10 @@ local function register_rope_block(multiple, pixels) } }) end + + if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", "vines:rope", "nodes", string.format("vines:%irope_block", multiple)) + end end --creates rope blocks with length multiples 1-5. @@ -83,6 +88,8 @@ register_rope_block(5, 12) minetest.register_node("vines:rope", { description = "Rope", + _doc_items_longdesc = vines.doc.ropebox_longdesc, + _doc_items_usagehelp = vines.doc.ropebox_usage, walkable = false, climbable = true, sunlight_propagates = true, @@ -103,6 +110,7 @@ minetest.register_node("vines:rope", { minetest.register_node("vines:rope_bottom", { description = "Rope", + _doc_items_create_entry = false, walkable = false, climbable = true, sunlight_propagates = true, @@ -146,6 +154,7 @@ minetest.register_node("vines:rope_bottom", { minetest.register_node("vines:rope_top", { description = "Rope", + _doc_items_create_entry = false, walkable = false, climbable = true, sunlight_propagates = true,