From 6a751a6b69b0fb44452bd65be2cba2ec16cf06cc Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 16 Jan 2017 12:47:32 +0100 Subject: [PATCH] Add mcstair mod for corner stairs --- mods/mcstair/README.md | 49 ++ mods/mcstair/depends.txt | 1 + mods/mcstair/description.txt | 1 + mods/mcstair/init.lua | 673 ++++++++++++++++++ mods/mcstair/mod.conf | 1 + mods/mcstair/textures/mcstair_turntexture.png | Bin 0 -> 170 bytes 6 files changed, 725 insertions(+) create mode 100644 mods/mcstair/README.md create mode 100644 mods/mcstair/depends.txt create mode 100644 mods/mcstair/description.txt create mode 100644 mods/mcstair/init.lua create mode 100644 mods/mcstair/mod.conf create mode 100644 mods/mcstair/textures/mcstair_turntexture.png diff --git a/mods/mcstair/README.md b/mods/mcstair/README.md new file mode 100644 index 000000000..f2b284397 --- /dev/null +++ b/mods/mcstair/README.md @@ -0,0 +1,49 @@ +mcstair v1.0 + +Minecraft like corner stairs. + +License for all of this mod is "CC0", see below. + +```txt +CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. + +Statement of Purpose +The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). +Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. +For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: + i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); + iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and + vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. + +4. Limitations and Disclaimers. + a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. + d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. +``` + +mod api: + +```lua +mcstair.add(name, stairtiles) +``` + +"name" is the name of the node to make corner stairs for. + +"stairtiles" is an optional table of tiles to override textures for inner and outer stairs. + +"stairtiles" format is... + +```lua +{tiles_def_for_outer_stair, tiles_def_for_inner_stair} +``` diff --git a/mods/mcstair/depends.txt b/mods/mcstair/depends.txt new file mode 100644 index 000000000..e95acbcad --- /dev/null +++ b/mods/mcstair/depends.txt @@ -0,0 +1 @@ +stairs \ No newline at end of file diff --git a/mods/mcstair/description.txt b/mods/mcstair/description.txt new file mode 100644 index 000000000..382c48079 --- /dev/null +++ b/mods/mcstair/description.txt @@ -0,0 +1 @@ +Minecraft like corner stairs. \ No newline at end of file diff --git a/mods/mcstair/init.lua b/mods/mcstair/init.lua new file mode 100644 index 000000000..ef00c2180 --- /dev/null +++ b/mods/mcstair/init.lua @@ -0,0 +1,673 @@ +mcstair = {} + +local get_stair_param = function(node) + local stair = minetest.get_item_group(node.name, "stair") + if stair == 1 then + return node.param2 + elseif stair == 2 then + if node.param2 < 12 then + return node.param2 + 4 + else + return node.param2 - 4 + end + elseif stair == 3 then + if node.param2 < 12 then + return node.param2 + 8 + else + return node.param2 - 8 + end + end +end + +local get_stair_from_param = function(param, stairs) + if param < 12 then + if param < 4 then + return {name = stairs[1], param2 = param} + elseif param < 8 then + return {name = stairs[2], param2 = param - 4} + else + return {name = stairs[3], param2 = param - 8} + end + else + if param >= 20 then + return {name = stairs[1], param2 = param} + elseif param >= 16 then + return {name = stairs[2], param2 = param + 4} + else + return {name = stairs[3], param2 = param + 8} + end + end +end + +local stair_param_to_connect = function(param, ceiling) + local out = {false, false, false, false, false, false, false, false} + if not ceiling then + if param == 0 then + out[3] = true + out[8] = true + elseif param == 1 then + out[2] = true + out[5] = true + elseif param == 2 then + out[4] = true + out[7] = true + elseif param == 3 then + out[1] = true + out[6] = true + elseif param == 4 then + out[1] = true + out[8] = true + elseif param == 5 then + out[2] = true + out[3] = true + elseif param == 6 then + out[4] = true + out[5] = true + elseif param == 7 then + out[6] = true + out[7] = true + elseif param == 8 then + out[3] = true + out[6] = true + elseif param == 9 then + out[5] = true + out[8] = true + elseif param == 10 then + out[2] = true + out[7] = true + elseif param == 11 then + out[1] = true + out[4] = true + end + else + if param == 12 then + out[5] = true + out[8] = true + elseif param == 13 then + out[3] = true + out[6] = true + elseif param == 14 then + out[1] = true + out[4] = true + elseif param == 15 then + out[2] = true + out[7] = true + elseif param == 16 then + out[2] = true + out[3] = true + elseif param == 17 then + out[1] = true + out[8] = true + elseif param == 18 then + out[6] = true + out[7] = true + elseif param == 19 then + out[4] = true + out[5] = true + elseif param == 20 then + out[3] = true + out[8] = true + elseif param == 21 then + out[1] = true + out[6] = true + elseif param == 22 then + out[4] = true + out[7] = true + elseif param == 23 then + out[2] = true + out[5] = true + end + end + return out +end + +local stair_connect_to_param = function(connect, ceiling) + local param + if not ceiling then + if connect[3] and connect[8] then + param = 0 + elseif connect[2] and connect[5] then + param = 1 + elseif connect[4] and connect[7] then + param = 2 + elseif connect[1] and connect[6] then + param = 3 + elseif connect[1] and connect[8] then + param = 4 + elseif connect[2] and connect[3] then + param = 5 + elseif connect[4] and connect[5] then + param = 6 + elseif connect[6] and connect[7] then + param = 7 + elseif connect[3] and connect[6] then + param = 8 + elseif connect[5] and connect[8] then + param = 9 + elseif connect[2] and connect[7] then + param = 10 + elseif connect[1] and connect[4] then + param = 11 + end + else + if connect[5] and connect[8] then + param = 12 + elseif connect[3] and connect[6] then + param = 13 + elseif connect[1] and connect[4] then + param = 14 + elseif connect[2] and connect[7] then + param = 15 + elseif connect[2] and connect[3] then + param = 16 + elseif connect[1] and connect[8] then + param = 17 + elseif connect[6] and connect[7] then + param = 18 + elseif connect[4] and connect[5] then + param = 19 + elseif connect[3] and connect[8] then + param = 20 + elseif connect[1] and connect[6] then + param = 21 + elseif connect[4] and connect[7] then + param = 22 + elseif connect[2] and connect[5] then + param = 23 + end + end + return param +end + +function mcstair.add(name, stairtiles) + local node_def = minetest.registered_nodes[name] + local outer_tiles + local inner_tiles + if stairtiles then + outer_tiles = stairtiles[1] + inner_tiles = stairtiles[2] + else + outer_tiles = node_def.tiles + inner_tiles = node_def.tiles + end + local outer_groups = table.copy(node_def.groups) + outer_groups.not_in_creative_inventory = 1 + local inner_groups = table.copy(outer_groups) + outer_groups.stair = 2 + inner_groups.stair = 3 + local drop = node_def.drop or name + local after_dig_node = function(pos, oldnode) + local param = get_stair_param(oldnode) + local ceiling + if param < 12 then + ceiling = false + else + ceiling = true + end + local connect = stair_param_to_connect(param, ceiling) + local t = { + {pos = {x = pos.x, y = pos.y, z = pos.z + 2}}, + {pos = {x = pos.x - 1, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z + 1}}, + {pos = {x = pos.x - 2, y = pos.y, z = pos.z}}, {pos = {x = pos.x - 1, y = pos.y, z = pos.z}}, + {pos = pos, connect = connect}, + {pos = {x = pos.x + 1, y = pos.y, z = pos.z}}, {pos = {x = pos.x + 2, y = pos.y, z = pos.z}}, + {pos = {x = pos.x - 1, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z - 1}}, + {pos = {x = pos.x, y = pos.y, z = pos.z - 2}} + } + for i,v in ipairs(t) do + if not v.connect then + local node = minetest.get_node(v.pos) + local node_def = minetest.registered_nodes[node.name] + if node_def.stairs then + t[i].stairs = node_def.stairs + t[i].connect = stair_param_to_connect(get_stair_param(node), ceiling) + else + t[i].connect = {false, false, false, false, false, false, false, false} + end + end + end + local swap_stair = function(index, n1, n2) + local connect = {false, false, false, false, false, false, false, false} + connect[n1] = true + connect[n2] = true + local node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[index].stairs) + minetest.swap_node(t[index].pos, node) + end + if t[3].stairs then + if t[7].connect[1] and t[3].connect[6] then + if t[3].connect[1] and t[1].connect[6] then + if t[2].connect[3] then + swap_stair(3, 1, 8) + elseif t[4].connect[7] then + swap_stair(3, 1, 4) + end + elseif t[3].connect[7] then + swap_stair(3, 4, 7) + elseif t[3].connect[3] then + swap_stair(3, 3, 8) + end + elseif t[7].connect[2] and t[3].connect[5] then + if t[3].connect[2] and t[1].connect[5] then + if t[4].connect[8] then + swap_stair(3, 2, 3) + elseif t[2].connect[4] then + swap_stair(3, 2, 7) + end + elseif t[3].connect[4] then + swap_stair(3, 4, 7) + elseif t[3].connect[8] then + swap_stair(3, 3, 8) + end + end + end + if t[8].stairs then + if t[7].connect[3] and t[8].connect[8] then + if t[8].connect[3] and t[9].connect[8] then + if t[4].connect[5] then + swap_stair(8, 2, 3) + elseif t[12].connect[1] then + swap_stair(8, 3, 6) + end + elseif t[8].connect[1] then + swap_stair(8, 1, 6) + elseif t[8].connect[5] then + swap_stair(8, 2, 5) + end + elseif t[7].connect[4] and t[8].connect[7] then + if t[8].connect[4] and t[9].connect[7] then + if t[12].connect[2] then + swap_stair(8, 4, 5) + elseif t[4].connect[6] then + swap_stair(8, 1, 4) + end + elseif t[8].connect[6] then + swap_stair(8, 1, 6) + elseif t[8].connect[2] then + swap_stair(8, 2, 5) + end + end + end + if t[11].stairs then + if t[7].connect[5] and t[11].connect[2] then + if t[11].connect[5] and t[13].connect[2] then + if t[12].connect[7] then + swap_stair(11, 4, 5) + elseif t[10].connect[3] then + swap_stair(11, 5, 8) + end + elseif t[11].connect[3] then + swap_stair(11, 3, 8) + elseif t[11].connect[7] then + swap_stair(11, 4, 7) + end + elseif t[7].connect[6] and t[11].connect[1] then + if t[11].connect[6] and t[13].connect[1] then + if t[10].connect[4] then + swap_stair(11, 6, 7) + elseif t[12].connect[8] then + swap_stair(11, 3, 6) + end + elseif t[11].connect[8] then + swap_stair(11, 3, 8) + elseif t[11].connect[4] then + swap_stair(11, 4, 7) + end + end + end + if t[6].stairs then + if t[7].connect[7] and t[6].connect[4] then + if t[6].connect[7] and t[5].connect[4] then + if t[10].connect[1] then + swap_stair(6, 6, 7) + elseif t[2].connect[5] then + swap_stair(6, 2, 7) + end + elseif t[6].connect[5] then + swap_stair(6, 2, 5) + elseif t[6].connect[1] then + swap_stair(6, 1, 6) + end + elseif t[7].connect[8] and t[6].connect[3] then + if t[6].connect[8] and t[5].connect[3] then + if t[2].connect[6] then + swap_stair(6, 1, 8) + elseif t[10].connect[2] then + swap_stair(6, 5, 8) + end + elseif t[6].connect[2] then + swap_stair(6, 2, 5) + elseif t[6].connect[6] then + swap_stair(6, 1, 6) + end + end + end + end + minetest.override_item(name, { + stairs = {name, name.."_outer", name.."_inner"}, + after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end, + on_place = nil, + after_place_node = function(pos, placer, itemstack, pointed_thing) + local node = minetest.get_node(pos) + local ceiling = false + if pointed_thing.under.y > pointed_thing.above.y then + ceiling = true + if node.param2 == 0 then node.param2 = 20 + elseif node.param2 == 1 then node.param2 = 23 + elseif node.param2 == 2 then node.param2 = 22 + elseif node.param2 == 3 then node.param2 = 21 + end + end + local connect = stair_param_to_connect(get_stair_param(node), ceiling) + local t = { + {pos = {x = pos.x - 1, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z + 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z + 1}}, + {pos = {x = pos.x - 1, y = pos.y, z = pos.z}}, {pos = pos, stairs = {name, name.."_outer", name.."_inner"}, connect = connect}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z}}, + {pos = {x = pos.x - 1, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x, y = pos.y, z = pos.z - 1}}, {pos = {x = pos.x + 1, y = pos.y, z = pos.z - 1}}, + } + for i,v in ipairs(t) do + if not v.connect then + local node = minetest.get_node(v.pos) + local node_def = minetest.registered_nodes[node.name] + if node_def.stairs then + t[i].stairs = node_def.stairs + t[i].connect = stair_param_to_connect(get_stair_param(node), ceiling) + else + t[i].connect = {false, false, false, false, false, false, false, false} + end + end + end + local reset_node = function(n1, n2) + local connect = {false, false, false, false, false, false, false, false} + connect[n1] = true + connect[n2] = true + node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[5].stairs) + end + local swap_stair = function(index, n1, n2) + local connect = {false, false, false, false, false, false, false, false} + connect[n1] = true + connect[n2] = true + local node = get_stair_from_param(stair_connect_to_param(connect, ceiling), t[index].stairs) + t[index].connect = connect + minetest.swap_node(t[index].pos, node) + end + if connect[3] then + if t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then + swap_stair(4, 2, 3) + elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then + swap_stair(4, 3, 6) + end + if t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then + swap_stair(6, 1, 8) + elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then + swap_stair(6, 5, 8) + end + if t[4].connect[3] ~= t[6].connect[8] then + if t[4].connect[3] then + if t[2].connect[6] then + reset_node(1, 8) + elseif t[8].connect[2] then + reset_node(5, 8) + elseif t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then + swap_stair(2, 6, 7) + reset_node(1, 8) + elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then + swap_stair(2, 3, 6) + reset_node(1, 8) + elseif t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then + swap_stair(8, 2, 3) + reset_node(5, 8) + elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then + swap_stair(8, 2, 7) + reset_node(5, 8) + end + else + if t[2].connect[5] then + reset_node(2, 3) + elseif t[8].connect[1] then + reset_node(3, 6) + elseif t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then + swap_stair(2, 4, 5) + reset_node(2, 3) + elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then + swap_stair(2, 5, 8) + reset_node(2, 3) + elseif t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then + swap_stair(8, 1, 8) + reset_node(3, 6) + elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then + swap_stair(8, 1, 4) + reset_node(3, 6) + end + end + end + elseif connect[2] then + if t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then + swap_stair(2, 4, 5) + elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then + swap_stair(2, 5, 8) + end + if t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then + swap_stair(8, 2, 3) + elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then + swap_stair(8, 2, 7) + end + if t[2].connect[5] ~= t[8].connect[2] then + if t[2].connect[5] then + if t[6].connect[8] then + reset_node(2, 3) + elseif t[4].connect[4] then + reset_node(2, 7) + elseif t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then + swap_stair(6, 1, 8) + reset_node(2, 3) + elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then + swap_stair(6, 5, 8) + reset_node(2, 3) + elseif t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then + swap_stair(4, 4, 5) + reset_node(2, 7) + elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then + swap_stair(4, 1, 4) + reset_node(2, 7) + end + else + if t[6].connect[7] then + reset_node(4, 5) + elseif t[4].connect[3] then + reset_node(5, 8) + elseif t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then + swap_stair(6, 6, 7) + reset_node(4, 5) + elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then + swap_stair(6, 2, 7) + reset_node(4, 5) + elseif t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then + swap_stair(4, 2, 3) + reset_node(5, 8) + elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then + swap_stair(4, 3, 6) + reset_node(5, 8) + end + end + end + elseif connect[4] then + if t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then + swap_stair(6, 6, 7) + elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then + swap_stair(6, 2, 7) + end + if t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then + swap_stair(4, 4, 5) + elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then + swap_stair(4, 1, 4) + end + if t[4].connect[4] ~= t[6].connect[7] then + if t[4].connect[4] then + if t[8].connect[1] then + reset_node(6, 7) + elseif t[2].connect[5] then + reset_node(2, 7) + elseif t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then + swap_stair(8, 1, 8) + reset_node(6, 7) + elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then + swap_stair(8, 1, 4) + reset_node(6, 7) + elseif t[2].connect[4] and t[2].connect[7] and t[3].connect[7] and not t[1].connect[4] then + swap_stair(2, 4, 5) + reset_node(2, 7) + elseif t[2].connect[3] and t[2].connect[8] and t[1].connect[3] and not t[3].connect[8] then + swap_stair(2, 5, 8) + reset_node(2, 7) + end + else + if t[8].connect[2] then + reset_node(4, 5) + elseif t[2].connect[6] then + reset_node(1, 4) + elseif t[8].connect[3] and t[8].connect[8] and t[9].connect[8] and not t[7].connect[3] then + swap_stair(8, 2, 3) + reset_node(4, 5) + elseif t[8].connect[4] and t[8].connect[7] and t[7].connect[4] and not t[9].connect[7] then + swap_stair(8, 2, 7) + reset_node(4, 5) + elseif t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then + swap_stair(2, 6, 7) + reset_node(1, 4) + elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then + swap_stair(2, 3, 6) + reset_node(1, 4) + end + end + end + elseif connect[1] then + if t[8].connect[3] and t[8].connect[8] and t[7].connect[3] and not t[9].connect[8] then + swap_stair(8, 1, 8) + elseif t[8].connect[4] and t[8].connect[7] and t[9].connect[7] and not t[7].connect[4] then + swap_stair(8, 1, 4) + end + if t[2].connect[4] and t[2].connect[7] and t[1].connect[4] and not t[3].connect[7] then + swap_stair(2, 6, 7) + elseif t[2].connect[3] and t[2].connect[8] and t[3].connect[8] and not t[1].connect[3] then + swap_stair(2, 3, 6) + end + if t[2].connect[6] ~= t[8].connect[1] then + if t[2].connect[6] then + if t[4].connect[3] then + reset_node(1, 8) + elseif t[6].connect[7] then + reset_node(1, 4) + elseif t[4].connect[2] and t[4].connect[5] and t[1].connect[5] and not t[7].connect[2] then + swap_stair(4, 2, 3) + reset_node(1, 8) + elseif t[4].connect[1] and t[4].connect[6] and t[7].connect[1] and not t[1].connect[6] then + swap_stair(4, 3, 6) + reset_node(1, 8) + elseif t[6].connect[1] and t[6].connect[6] and t[9].connect[1] and not t[3].connect[6] then + swap_stair(6, 6, 7) + reset_node(1, 4) + elseif t[6].connect[2] and t[6].connect[5] and t[3].connect[5] and not t[9].connect[2] then + swap_stair(6, 2, 7) + reset_node(1, 4) + end + else + if t[4].connect[4] then + reset_node(6, 7) + elseif t[6].connect[8] then + reset_node(3, 6) + elseif t[4].connect[2] and t[4].connect[5] and t[7].connect[2] and not t[1].connect[5] then + swap_stair(4, 4, 5) + reset_node(6, 7) + elseif t[4].connect[1] and t[4].connect[6] and t[1].connect[6] and not t[7].connect[1] then + swap_stair(4, 1, 4) + reset_node(6, 7) + elseif t[6].connect[1] and t[6].connect[6] and t[3].connect[6] and not t[9].connect[1] then + swap_stair(6, 1, 8) + reset_node(3, 6) + elseif t[6].connect[2] and t[6].connect[5] and t[9].connect[2] and not t[3].connect[5] then + swap_stair(6, 5, 8) + reset_node(3, 6) + end + end + end + end + minetest.swap_node(pos, node) + end + }) + minetest.register_node(":"..name.."_outer", { + description = node_def.description, + drawtype = "nodebox", + tiles = outer_tiles, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + groups = outer_groups, + sounds = node_def.sounds, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + {-0.5, 0, 0, 0, 0.5, 0.5} + } + }, + drop = drop, + stairs = {name, name.."_outer", name.."_inner"}, + after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end + }) + minetest.register_node(":"..name.."_inner", { + description = node_def.description, + drawtype = "nodebox", + tiles = inner_tiles, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + groups = inner_groups, + sounds = node_def.sounds, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + {-0.5, 0, 0, 0.5, 0.5, 0.5}, + {-0.5, 0, -0.5, 0, 0.5, 0} + } + }, + drop = drop, + stairs = {name, name.."_outer", name.."_inner"}, + after_dig_node = function(pos, oldnode) after_dig_node(pos, oldnode) end + }) +end + +for _,v in ipairs({ + "wood", + "junglewood", + "sprucewood", + "acaciawood", + "birchwood", + "darkwood" +}) do + local t = minetest.registered_nodes["default:"..v].tiles[1] + mcstair.add("stairs:stair_"..v, { + { + t.."^("..t.."^[transformR90^mcstair_turntexture.png^[makealpha:255,0,255)", + t.."^("..t.."^mcstair_turntexture.png^[transformR270^[makealpha:255,0,255)", + t + }, + { + t.."^("..t.."^[transformR90^(mcstair_turntexture.png^[transformR180)^[makealpha:255,0,255)", + t.."^("..t.."^[transformR270^(mcstair_turntexture.png^[transformR90)^[makealpha:255,0,255)", + t + } + }) +end + +for _,v in ipairs({ + "stone", + "cobble", + "brick", + "sandstone", + "redsandstone", + "stonebrick", + "quartzblock", + "purpur_block", +}) do + mcstair.add("stairs:stair_"..v) +end diff --git a/mods/mcstair/mod.conf b/mods/mcstair/mod.conf new file mode 100644 index 000000000..c0546d6d0 --- /dev/null +++ b/mods/mcstair/mod.conf @@ -0,0 +1 @@ +name = mcstair diff --git a/mods/mcstair/textures/mcstair_turntexture.png b/mods/mcstair/textures/mcstair_turntexture.png new file mode 100644 index 0000000000000000000000000000000000000000..6a2e8db131e211493efdba742269ff2244a1e47d GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!D3?x-;bCrM;TYyi9E0F%r@Zaoj(t03^u_VYZ zn8D%MjWi&Kv%n*=n1O*?7=#%aX3dcR3bL1Y`ns||WaJT$Vp6F;!vPf1@^onYg32%Qv!ZTU?W%gkyyTVWZ{GW&RX|+~p00i_ I>zopr054-L;s5{u literal 0 HcmV?d00001