diff --git a/crafts.lua b/crafts.lua index 05c467f..299c0cc 100644 --- a/crafts.lua +++ b/crafts.lua @@ -6,9 +6,9 @@ if minetest.get_modpath("farming") then minetest.register_craft({ output = 'ropes:ropesegment', recipe = { - {'farming:cotton',}, - {'farming:cotton',}, - {'farming:cotton'} + {'farming:cotton','farming:cotton'}, + {'farming:cotton','farming:cotton'}, + {'farming:cotton','farming:cotton'} } }) end @@ -21,68 +21,14 @@ minetest.register_craftitem("ropes:ropesegment", { inventory_image = "ropes_item.png", }) -minetest.register_craft({ - output = "ropes:ropeladder_top", - recipe = { - {'group:vines','group:stick','group:vines'}, - {'group:vines','group:stick','group:vines'}, - } -}) - -minetest.register_craft({ - output = "ropes:1rope_block", - recipe = { - {'group:wood',}, - {'group:vines',}, - {'group:vines'} - } -}) - local cotton_burn_time = 1 -local wood_burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack("default:wood")}}).time -local rope_burn_time = cotton_burn_time * 3 -local rope_box_burn_time = wood_burn_time + rope_burn_time * 2 +ropes.wood_burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack("default:wood")}}).time +ropes.rope_burn_time = cotton_burn_time * 6 local stick_burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack("default:stick")}}).time -local ladder_burn_time = rope_burn_time * 2 + stick_burn_time * 2 +ropes.ladder_burn_time = ropes.rope_burn_time * 2 + stick_burn_time * 3 minetest.register_craft({ type = "fuel", recipe = "ropes:ropesegment", - burntime = rope_burn_time, -}) - -minetest.register_craft({ - type = "fuel", - recipe = "ropes:1rope_block", - burntime = rope_box_burn_time, -}) - -minetest.register_craft({ - type = "fuel", - recipe = "ropes:2rope_block", - burntime = rope_box_burn_time * 2, -}) - -minetest.register_craft({ - type = "fuel", - recipe = "ropes:3rope_block", - burntime = rope_box_burn_time * 3, -}) - -minetest.register_craft({ - type = "fuel", - recipe = "ropes:4rope_block", - burntime = rope_box_burn_time * 4, -}) - -minetest.register_craft({ - type = "fuel", - recipe = "ropes:5rope_block", - burntime = rope_box_burn_time * 5, -}) - -minetest.register_craft({ - type = "fuel", - recipe = "ropes:ropeladder_top", - burntime = ladder_burn_time, + burntime = ropes.rope_burn_time, }) \ No newline at end of file diff --git a/doc.lua b/doc.lua index 35f1cdc..7f2ce54 100644 --- a/doc.lua +++ b/doc.lua @@ -14,17 +14,30 @@ ropes.doc.ropesegment_usage = S("This craft item is useful for creating rope lad ropes.doc.ropeladder_longdesc = S("A hanging rope ladder that automatically extends downward.") ropes.doc.ropeladder_usage = S("After a rope ladder is placed on a vertical wall it will begin extending downward until it reaches its maximum length (@1 meters). 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.", ropes.ropeLadderLength) -local rope_length_doc -if ropes.ropeLengthMaxMultiple > 1 then - rope_length_doc = S("Rope boxes have a certain amount of rope contained within them specified in the name of the node. They come in @1 standard lengths (from @2 meters to @3 meters in multiples of @2 meters) that can be crafted by combining and splitting up rope boxes in the crafting grid. For example, you can craft a @4m rope box by combining two @2m rope boxes, and the two @2m rope boxes can be recovered by splitting the @4m rope box back up in the crafting grid.", ropes.ropeLengthMaxMultiple, ropes.ropeLength, ropes.ropeLength*ropes.ropeLengthMaxMultiple, ropes.ropeLength*2) -else - rope_length_doc = S("Rope boxes contain @1 meters of rope.", ropes.ropeLength) +local rope_length_doc = S("Rope boxes have a certain amount of rope contained within them specified in the name of the node, and have a limit to how much rope they can support that depends on the material they're made of. The different lengths can be crafted by combining and splitting up rope boxes in the crafting grid. For example, you can craft a @1m rope box by putting a @2m rope box and a rope segment in the crafting grid, or a @3m rope box and two rope segments in the crafting grid. Two rope segments can be recovered by putting the @1m rope box in the crafting grid by itself.", ropes.ropeLength*3, ropes.ropeLength*2, ropes.ropeLength) .. "\n" + +if ropes.woodRopeBoxMaxMultiple == 1 then + rope_length_doc = rope_length_doc .. "\n" .. S("Wood") .. " " .. S("rope boxes can hold @1m of rope.", ropes.ropeLength) +elseif ropes.woodRopeBoxMaxMultiple > 1 then + rope_length_doc = rope_length_doc .. "\n" .. S("Wood") .. " " .. S("rope boxes can hold rope lengths from @1m to @2m.", ropes.ropeLength, ropes.ropeLength*ropes.woodRopeBoxMaxMultiple) +end + +if ropes.copperRopeBoxMaxMultiple == 1 then + rope_length_doc = rope_length_doc .. "\n" .. S("Copper") .. " " .. S("rope boxes can hold @1m of rope.", ropes.ropeLength) +elseif ropes.copperRopeBoxMaxMultiple > 1 then + rope_length_doc = rope_length_doc .. "\n" .. S("Copper") .. " " .. S("rope boxes can hold rope lengths from @1m to @2m.", ropes.ropeLength, ropes.ropeLength*ropes.copperRopeBoxMaxMultiple) +end + +if ropes.steelRopeBoxMaxMultiple == 1 then + rope_length_doc = rope_length_doc .. "\n" .. S("Steel") .. " " .. S("rope boxes can hold @1m of rope.", ropes.ropeLength) +elseif ropes.steelRopeBoxMaxMultiple > 1 then + rope_length_doc = rope_length_doc .. "\n" .. S("Steel") .. " " .. S("rope boxes can hold rope lengths from @1m to @2m.", ropes.ropeLength, ropes.ropeLength*ropes.steelRopeBoxMaxMultiple) end ropes.doc.ropebox_longdesc = S("Ropes are hung by placing rope boxes, which automatically lower a rope of fixed length below them. They can be climbed and cut.") 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. Take care not to fall off the end! 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 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.") + 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.") doc.add_entry_alias("nodes", "ropes:ropeladder_top", "nodes", "ropes:ropeladder") doc.add_entry_alias("nodes", "ropes:ropeladder_top", "nodes", "ropes:ropeladder_bottom") diff --git a/init.lua b/init.lua index 65374cf..0f72933 100644 --- a/init.lua +++ b/init.lua @@ -16,11 +16,24 @@ if not ropes.ropeLadderLength then ropes.ropeLadderLength = 50 end -ropes.ropeLengthMaxMultiple = tonumber(minetest.setting_get("ropes_rope_box_max_multiple")) -if not ropes.ropeLengthMaxMultiple then - ropes.ropeLengthMaxMultiple = 9 +ropes.woodRopeBoxMaxMultiple = tonumber(minetest.setting_get("ropes_wood_rope_box_max_multiple")) +if not ropes.woodRopeBoxMaxMultiple then + ropes.woodRopeBoxMaxMultiple = 2 end +ropes.copperRopeBoxMaxMultiple = tonumber(minetest.setting_get("ropes_copper_rope_box_max_multiple")) +if not ropes.copperRopeBoxMaxMultiple then + ropes.copperRopeBoxMaxMultiple = 5 +end + +ropes.steelRopeBoxMaxMultiple = tonumber(minetest.setting_get("ropes_steel_rope_box_max_multiple")) +if not ropes.steelRopeBoxMaxMultiple then + ropes.steelRopeBoxMaxMultiple = 9 +end + +ropes.create_all_definitions = minetest.setting_getbool("ropes_create_all_definitions") + + dofile( minetest.get_modpath( ropes.name ) .. "/doc.lua" ) dofile( minetest.get_modpath( ropes.name ) .. "/functions.lua" ) dofile( minetest.get_modpath( ropes.name ) .. "/crafts.lua" ) @@ -29,9 +42,9 @@ dofile( minetest.get_modpath( ropes.name ) .. "/ladder.lua" ) local upgrade_counter = 1 -- For players who used to use the combined vine/rope mod fork I split this out of -local swapper = function(old_node, new_node) +local swapper = function(old_node, new_node, upgrade_name) minetest.register_lbm({ - name = "ropes:vines_to_ropes_upgrade_" .. tostring(upgrade_counter), + name = "ropes:" .. upgrade_name .. "_" .. tostring(upgrade_counter), nodenames = {old_node}, action = function(pos, node) minetest.swap_node(pos, {name=new_node, param2=node.param2}) @@ -40,16 +53,20 @@ local swapper = function(old_node, new_node) upgrade_counter = upgrade_counter + 1 end for i=1,5 do - swapper(string.format("vines:%irope_block", i), string.format("ropes:%irope_block", i)) + swapper(string.format("vines:%irope_block", i), string.format("ropes:%irope_block", i), "vines_to_ropes_upgrade") +end +swapper("vines:rope", "ropes:rope", "vines_to_ropes_upgrade") +swapper("vines:rope_bottom", "ropes:rope_bottom", "vines_to_ropes_upgrade") +swapper("vines:rope_end", "ropes:rope_bottom", "vines_to_ropes_upgrade") +swapper("vines:rope_top", "ropes:rope_top", "vines_to_ropes_upgrade") +swapper("vines:ropeladder_top", "ropes:ropeladder_top", "vines_to_ropes_upgrade") +swapper("vines:ropeladder", "ropes:ropeladder", "vines_to_ropes_upgrade") +swapper("vines:ropeladder_bottom", "ropes:ropeladder_bottom", "vines_to_ropes_upgrade") +swapper("vines:ropeladder_falling", "ropes:ropeladder_falling", "vines_to_ropes_upgrade") +swapper("vines:rope_block", "ropes:5rope_block", "vines_to_ropes_upgrade") -- for the original vines mod + +for i=1,9 do + swapper(string.format("ropes:%irope_block", i), string.format("ropes:wood%irope_block", i), "rope_block_composition_upgrade") end -swapper("vines:rope", "ropes:rope") -swapper("vines:rope_bottom", "ropes:rope_bottom") -swapper("vines:rope_end", "ropes:rope_bottom") -swapper("vines:rope_top", "ropes:rope_top") -swapper("vines:ropeladder_top", "ropes:ropeladder_top") -swapper("vines:ropeladder", "ropes:ropeladder") -swapper("vines:ropeladder_bottom", "ropes:ropeladder_bottom") -swapper("vines:ropeladder_falling", "ropes:ropeladder_falling") -swapper("vines:rope_block", "ropes:5rope_block") -- for the original vines mod print(S("[Ropes] Loaded!")) diff --git a/ladder.lua b/ladder.lua index cb9f343..5ac872c 100644 --- a/ladder.lua +++ b/ladder.lua @@ -1,8 +1,29 @@ +if ropes.ropeLadderLength == 0 and not ropes.create_all_definitions then + return +end + -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) local S, NS = dofile(MP.."/intllib.lua") -minetest.register_node("ropes:ropeladder_top", { +if ropes.ropeLadderLength > 0 then + minetest.register_craft({ + output = "ropes:ropeladder_top", + recipe = { + {'','group:stick',''}, + {'group:vines','group:stick','group:vines'}, + {'','group:stick',''}, + } + }) +end + +minetest.register_craft({ + type = "fuel", + recipe = "ropes:ropeladder_top", + burntime = ropes.ladder_burn_time, +}) + +local rope_ladder_top_def = { description = S("Rope Ladder"), _doc_items_longdesc = ropes.doc.ropeladder_longdesc, _doc_items_usagehelp = ropes.doc.ropeladder_usage, @@ -45,7 +66,13 @@ minetest.register_node("ropes:ropeladder_top", { local pos_below = {x=pos.x, y=pos.y-1, z=pos.z} ropes.destroy_rope(pos_below, {"ropes:ropeladder", "ropes:ropeladder_bottom", "ropes:ropeladder_falling"}) end, -}) +} + +if ropes.ropeLadderLength == 0 then + rope_ladder_top_def.groups.not_in_creative_inventory = 1 +end + +minetest.register_node("ropes:ropeladder_top", rope_ladder_top_def) minetest.register_node("ropes:ropeladder", { description = S("Rope Ladder"), diff --git a/locale/template.pot b/locale/template.pot index 28ebcbf..3d739ab 100644 --- a/locale/template.pot +++ b/locale/template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-02-09 00:20-0700\n" +"POT-Creation-Date: 2017-02-09 21:21-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,20 +16,8 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: init.lua:57 -msgid "[Ropes] Loaded!" -msgstr "" - -#: ropeboxes.lua:120 -msgid "Rope @1m" -msgstr "" - -#: ropeboxes.lua:202 ropeboxes.lua:233 -msgid "Rope" -msgstr "" - -#: ladder.lua:6 ladder.lua:51 ladder.lua:81 ladder.lua:115 -msgid "Rope Ladder" +#: crafts.lua:17 +msgid "Rope Segment" msgstr "" #: doc.lua:11 @@ -58,45 +46,78 @@ msgid "" "length as before." msgstr "" -#: doc.lua:19 +#: doc.lua:17 msgid "" "Rope boxes have a certain amount of rope contained within them specified in " -"the name of the node. They come in @1 standard lengths (from @2 meters to @3 " -"meters in multiples of @2 meters) that can be crafted by combining and " -"splitting up rope boxes in the crafting grid. For example, you can craft a " -"@4m rope box by combining two @2m rope boxes, and the two @2m rope boxes can " -"be recovered by splitting the @4m rope box back up in the crafting grid." +"the name of the node, and have a limit to how much rope they can support " +"that depends on the material they're made of. The different lengths can be " +"crafted by combining and splitting up rope boxes in the crafting grid. For " +"example, you can craft a @1m rope box by putting a @2m rope box and a rope " +"segment in the crafting grid, or a @3m rope box and two rope segments in the " +"crafting grid. Two rope segments can be recovered by putting the @1m rope " +"box in the crafting grid by itself." msgstr "" -#: doc.lua:21 -msgid "Rope boxes contain @1 meters of rope." +#: doc.lua:20 doc.lua:22 ropeboxes.lua:302 +msgid "Wood" msgstr "" -#: doc.lua:24 +#: 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 +msgid "rope boxes can hold rope lengths from @1m to @2m." +msgstr "" + +#: doc.lua:26 doc.lua:28 ropeboxes.lua:319 +msgid "Copper" +msgstr "" + +#: doc.lua:32 doc.lua:34 ropeboxes.lua:336 +msgid "Steel" +msgstr "" + +#: doc.lua:37 msgid "" "Ropes are hung by placing rope boxes, which automatically lower a rope of " "fixed length below them. They can be climbed and cut." msgstr "" -#: doc.lua:26 +#: doc.lua:39 msgid "" "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! 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." +"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." msgstr "" -#: doc.lua:27 +#: doc.lua:40 msgid "" -"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 " +"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 " -"permnanently lost when a rope is severed like this." +"permanently lost when a rope is severed like this." +msgstr "" + +#: init.lua:72 +msgid "[Ropes] Loaded!" +msgstr "" + +#: ladder.lua:27 ladder.lua:78 ladder.lua:108 ladder.lua:142 +msgid "Rope Ladder" +msgstr "" + +#: ropeboxes.lua:121 +msgid "@1 Ropebox @2m" +msgstr "" + +#: ropeboxes.lua:218 ropeboxes.lua:249 +msgid "Rope" msgstr "" diff --git a/ropeboxes.lua b/ropeboxes.lua index c5ab8af..81e8885 100644 --- a/ropeboxes.lua +++ b/ropeboxes.lua @@ -2,14 +2,14 @@ local MP = minetest.get_modpath(minetest.get_current_modname()) local S, NS = dofile(MP.."/intllib.lua") -local function rope_box_tiles(count) +local function rope_box_tiles(count, tint) return { - string.format("ropes_ropebox_front_%i.png^ropes_%i.png", count, count), - string.format("ropes_ropebox_front_%i.png^ropes_%i.png", count, count), - "ropes_ropebox_side.png", - "ropes_ropebox_side.png", - string.format("ropes_ropebox_front_%i.png^ropes_%i.png", count, count), - string.format("ropes_ropebox_front_%i.png^ropes_%i.png", count, count), + string.format("ropes_ropebox_front_%i.png^[colorize:%s^ropes_ropebox_front_%i.png^ropes_%i.png", count, tint, count, count), + string.format("ropes_ropebox_front_%i.png^[colorize:%s^ropes_ropebox_front_%i.png^ropes_%i.png", count, tint, count, count), + string.format("ropes_ropebox_side.png^[colorize:%s^ropes_ropebox_side.png", tint), + string.format("ropes_ropebox_side.png^[colorize:%s^ropes_ropebox_side.png", tint), + string.format("ropes_ropebox_front_%i.png^[colorize:%s^ropes_ropebox_front_%i.png^ropes_%i.png", count, tint, count, count), + string.format("ropes_ropebox_front_%i.png^[colorize:%s^ropes_ropebox_front_%i.png^ropes_%i.png", count, tint, count, count), } end @@ -23,7 +23,7 @@ local rope_box_data = { {0.125, -0.5, -0.125, 0.1875, 0.125, 0.125}, -- support }, --selection = {-0.1875, -0.5, -0.25, 0.1875, 0.25, 0.25}, -- selection - tiles = rope_box_tiles(1), + tiles = 1, }, { node={ @@ -34,7 +34,7 @@ local rope_box_data = { {0.1875, -0.5, -0.125, 0.25, 0.125, 0.125}, -- support }, --selection = {-0.1875, -0.5, -0.25, 0.1875, 0.25, 0.25}, -- selection - tiles = rope_box_tiles(2), + tiles = 2, }, { node={ @@ -45,7 +45,7 @@ local rope_box_data = { {0.25, -0.5, -0.125, 0.3125, 0.125, 0.125}, -- support }, --selection = {-0.3125, -0.5, -0.25, 0.3125, 0.25, 0.25}, -- selection - tiles = rope_box_tiles(3), + tiles = 3, }, { node={ @@ -56,7 +56,7 @@ local rope_box_data = { {0.3125, -0.5, -0.125, 0.375, 0.125, 0.125}, -- support }, --selection = {-0.375, -0.5, -0.25, 0.375, 0.25, 0.25}, -- selection - tiles = rope_box_tiles(4), + tiles = 4, }, { node={ @@ -67,7 +67,7 @@ local rope_box_data = { {0.375, -0.5, -0.125, 0.4375, 0.125, 0.125}, -- support }, --selection = {-0.4375, -0.5, -0.25, 0.4375, 0.25, 0.25}, -- selection - tiles = rope_box_tiles(5), + tiles = 5, }, { node={ @@ -78,7 +78,7 @@ local rope_box_data = { {0.1875, -0.5, -0.125, 0.25, 0.125, 0.125}, -- support }, --selection = {-0.1875, -0.5, -0.3125, 0.1875, 0.3125, 0.3125}, -- selection - tiles = rope_box_tiles(2), + tiles = 2, }, { node={ @@ -89,7 +89,7 @@ local rope_box_data = { {0.25, -0.5, -0.125, 0.3125, 0.125, 0.125}, -- support }, --selection = {-0.3125, -0.5, -0.3125, 0.3125, 0.3125, 0.3125}, -- selection - tiles = rope_box_tiles(3), + tiles = 3, }, { node={ @@ -100,7 +100,7 @@ local rope_box_data = { {0.3125, -0.5, -0.125, 0.375, 0.125, 0.125}, -- support }, --selection = {-0.375, -0.5, -0.3125, 0.375, 0.3125, 0.3125}, -- selection - tiles = rope_box_tiles(4), + tiles = 4, }, { node={ @@ -111,13 +111,14 @@ local rope_box_data = { {0.375, -0.5, -0.125, 0.4375, 0.125, 0.125}, -- support }, --selection_bottom = {-0.4375, -0.5, -0.3125, 0.4375, 0.3125, 0.3125}, -- selection - tiles = rope_box_tiles(5), + tiles = 5, } } -local function register_rope_block(multiple) +local function register_rope_block(multiple, max_multiple, name_prefix, node_prefix, tint, flammable) + local node_name = string.format("ropes:%s%irope_block", node_prefix, multiple) local rope_block_def = { - description = S("Rope @1m", ropes.ropeLength*multiple), + description = S("@1 Ropebox @2m", name_prefix, ropes.ropeLength*multiple), _doc_items_create_entry = false, drawtype="nodebox", sunlight_propagates = true, @@ -125,14 +126,14 @@ local function register_rope_block(multiple) paramtype2 = "wallmounted", walkable = false, climbable = true, - tiles = rope_box_data[multiple].tiles, + tiles = rope_box_tiles(rope_box_data[multiple].tiles, tint), node_box = { type = "fixed", fixed = rope_box_data[multiple].node }, selection_box = {type="regular"}, collision_box = {type="regular"}, - groups = {flammable=2, choppy=2, oddly_breakable_by_hand=1, rope_block = 1}, + groups = {choppy=2, oddly_breakable_by_hand=1, rope_block = 1}, after_place_node = function(pos, placer) local pos_below = {x=pos.x, y=pos.y-1, z=pos.z} @@ -161,40 +162,55 @@ local function register_rope_block(multiple) -- some were already placed in-world) but we want to hide it from creative inventory -- and if someone digs it we want to disintegrate it into its component parts to prevent -- reuse. - if multiple > ropes.ropeLengthMaxMultiple then + if multiple > max_multiple then rope_block_def.groups.not_in_creative_inventory = 1 - rope_block_def.drop = string.format("ropes:1rope_block %i", multiple) + rope_block_def.drop = string.format("ropes:%s1rope_block %i", node_prefix, multiple) end - minetest.register_node(string.format("ropes:%irope_block", multiple), rope_block_def) + if flammable then + rope_block_def.groups.flammable = flammable + + minetest.register_craft({ + type = "fuel", + recipe = node_name, + burntime = ropes.rope_burn_time * multiple + ropes.wood_burn_time, + }) + end + + minetest.register_node(node_name, rope_block_def) if (multiple ~= 1) then -- Only register a recipe to craft this if it's within the permitted multiple range - if multiple <= ropes.ropeLengthMaxMultiple then - local rec = {} - for i=1,multiple,1 do - rec[i] = "ropes:1rope_block" + if multiple <= max_multiple then + for i = 1, multiple-1 do + local rec = {string.format("ropes:%s%irope_block", node_prefix, i)} + for n = 1, multiple-i do + table.insert(rec, "ropes:ropesegment") + end + minetest.register_craft({ + output = node_name, + type = "shapeless", + recipe = rec + }) end - - minetest.register_craft({ - output = string.format("ropes:%irope_block", multiple), - type = "shapeless", - recipe = rec - }) end -- Always allow players to disintegrate this into component parts, in case -- there were some in inventory and the setting was changed. minetest.register_craft({ - output = string.format("ropes:1rope_block %i", multiple), + output = "ropes:ropesegment", + type = "shapeless", recipe = { - {string.format('ropes:%irope_block', multiple)} - } + node_name + }, + replacements = { + {node_name, string.format('ropes:%s%irope_block', node_prefix, multiple-1)}, + }, }) end if minetest.get_modpath("doc") then - doc.add_entry_alias("nodes", "ropes:rope", "nodes", string.format("ropes:%irope_block", multiple)) + doc.add_entry_alias("nodes", "ropes:rope", "nodes", node_name) end end @@ -268,17 +284,56 @@ local rope_bottom_def = { end, } ---creates rope blocks with length multiples 1-5. ---second parameter sets how many pixels wide the rope texture is -register_rope_block(1) -register_rope_block(2) -register_rope_block(3) -register_rope_block(4) -register_rope_block(5) -register_rope_block(6) -register_rope_block(7) -register_rope_block(8) -register_rope_block(9) - minetest.register_node("ropes:rope", rope_def) -minetest.register_node("ropes:rope_bottom", rope_bottom_def) \ No newline at end of file +minetest.register_node("ropes:rope_bottom", rope_bottom_def) + +if ropes.woodRopeBoxMaxMultiple > 0 or ropes.create_all_definitions then + if ropes.woodRopeBoxMaxMultiple > 0 then + minetest.register_craft({ + output = "ropes:1rope_block", + recipe = { + {'group:wood'}, + {'group:vines'} + } + }) + end + for i = 1,9 do + if ropes.woodRopeBoxMaxMultiple >= i or ropes.create_all_definitions then + register_rope_block(i, ropes.woodRopeBoxMaxMultiple, S("Wood"), "wood", "#86683a", 2) + end + end +end + +if ropes.copperRopeBoxMaxMultiple > 0 or ropes.create_all_definitions then + if ropes.copperRopeBoxMaxMultiple > 0 then + minetest.register_craft({ + output = "ropes:1rope_block", + recipe = { + {'default:copper_ingot'}, + {'group:vines'} + } + }) + end + for i = 1,9 do + if ropes.copperRopeBoxMaxMultiple >= i or ropes.create_all_definitions then + register_rope_block(i, ropes.copperRopeBoxMaxMultiple, S("Copper"), "copper", "#c88648") + end + end +end + +if ropes.steelRopeBoxMaxMultiple > 0 or ropes.create_all_definitions then + if ropes.steelRopeBoxMaxMultiple > 0 then + minetest.register_craft({ + output = "ropes:1rope_block", + recipe = { + {'default:steel_ingot'}, + {'group:vines'} + } + }) + end + for i = 1,9 do + if ropes.steelRopeBoxMaxMultiple >= i or ropes.create_all_definitions then + register_rope_block(i, ropes.steelRopeBoxMaxMultiple, S("Steel"), "steel", "#ffffff") + end + end +end diff --git a/settingtypes.txt b/settingtypes.txt index bb0ad2a..242cd76 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -5,10 +5,33 @@ ropes_rope_length (Rope length) int 50 1 30000 #Rope ladders will extend this far at maximum. #Changing this value will not affect rope ladders that already exist in-world. -ropes_rope_ladder_length (Rope ladder length) int 50 1 30000 +#Setting this to 0 disables rope ladders. +ropes_rope_ladder_length (Rope ladder length) int 50 0 30000 -#Sets the maximum length multiple rope box permitted to be crafted. +#Sets the maximum length multiple wooden rope box permitted to be crafted. +#So for example if the rope length is set to 50 and this is set to 2, +#the longest possible wooden rope box a player can craft has 100 meters of rope. +#Allowed values run from 0 to 9. 0 disables wood rope boxes. +ropes_wood_rope_box_max_multiple (Maximum wood_rope box multiple) int 2 0 9 + +#Sets the maximum length multiple copper rope box permitted to be crafted. #So for example if the rope length is set to 50 and this is set to 5, -#the longest possible rope box a player can craft has 250 meters of rope. -#Allowed values run from 1 to 9 -ropes_rope_box_max_multiple (Maximum rope box multiple) int 9 1 9 \ No newline at end of file +#the longest possible copper rope box a player can craft has 250 meters of rope. +#Allowed values run from 0 to 9. 0 disables copper rope boxes. +ropes_copper_rope_box_max_multiple (Maximum copper rope box multiple) int 5 0 9 + +#Sets the maximum length multiple steel rope box permitted to be crafted. +#So for example if the rope length is set to 50 and this is set to 9, +#the longest possible steel rope box a player can craft has 450 meters of rope. +#Allowed values run from 0 to 9. 0 disables steel rope boxes. +ropes_steel_rope_box_max_multiple (Maximum steel rope box multiple) int 9 0 9 + +#If this is set to true, then the mod will generate definitions for the rope boxes +#that are otherwise not permitted by the settings above. These rope boxes +#will not be craftable and will not be available in the creative inventory, +#but they will continue to exist if they were placed "in world" and a player +#can deconstruct them to retrieve their rope components. This setting is +#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 \ No newline at end of file diff --git a/textures/ropes_ropebox_front_1.png b/textures/ropes_ropebox_front_1.png index da2ac5d..23b6067 100644 Binary files a/textures/ropes_ropebox_front_1.png and b/textures/ropes_ropebox_front_1.png differ diff --git a/textures/ropes_ropebox_front_2.png b/textures/ropes_ropebox_front_2.png index b3fe838..ee8c471 100644 Binary files a/textures/ropes_ropebox_front_2.png and b/textures/ropes_ropebox_front_2.png differ diff --git a/textures/ropes_ropebox_front_3.png b/textures/ropes_ropebox_front_3.png index 924b35f..4e420cd 100644 Binary files a/textures/ropes_ropebox_front_3.png and b/textures/ropes_ropebox_front_3.png differ diff --git a/textures/ropes_ropebox_front_4.png b/textures/ropes_ropebox_front_4.png index 608d7f6..cc0a10a 100644 Binary files a/textures/ropes_ropebox_front_4.png and b/textures/ropes_ropebox_front_4.png differ diff --git a/textures/ropes_ropebox_front_5.png b/textures/ropes_ropebox_front_5.png index 44ca683..e6eab8b 100644 Binary files a/textures/ropes_ropebox_front_5.png and b/textures/ropes_ropebox_front_5.png differ diff --git a/textures/ropes_ropebox_side.png b/textures/ropes_ropebox_side.png index 5584b54..37cfa10 100644 Binary files a/textures/ropes_ropebox_side.png and b/textures/ropes_ropebox_side.png differ