From 85975a2d2651f06a1039d0e25c56af1031d5fc2b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 29 May 2018 13:46:39 +0200 Subject: [PATCH] mcl_stairs: Add woodlike cornerstair mode --- mods/ITEMS/mcl_stairs/cornerstair.lua | 39 ++++++++++++++++++++------- mods/ITEMS/mcl_stairs/register.lua | 17 +----------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/mods/ITEMS/mcl_stairs/cornerstair.lua b/mods/ITEMS/mcl_stairs/cornerstair.lua index 100657ca8f..ab9377757a 100644 --- a/mods/ITEMS/mcl_stairs/cornerstair.lua +++ b/mods/ITEMS/mcl_stairs/cornerstair.lua @@ -187,25 +187,44 @@ end --[[ mcl_stairs.cornerstair.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: +NOTE: This function is used internally. If you register a stair, this function is already called, no +need to call it again! - {tiles_def_for_outer_stair, tiles_def_for_inner_stair} - -Note: This function is called when you register a stair, no need to call it again! +Usage: +* name is the name of the node to make corner stairs for. +* stairtiles is optional, can specify textures for inner and outer stairs. 3 data types are accepted: + * string: one of: + * "default": Use same textures as original node + * "woodlike": Take first frame of the original tiles, then take a triangle piece + of the texture, rotate it by 90° and overlay it over the original texture + * table: Specify textures explicitly. Table of tiles to override textures for + inner and outer stairs. Table format: + { tiles_def_for_outer_stair, tiles_def_for_inner_stair } + * nil: Equivalent to "default" ]] function mcl_stairs.cornerstair.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 + if stairtiles == "woodlike" then + local t = node_def.tiles[1] + outer_tiles = { + t.."^("..t.."^[transformR90^mcl_stairs_turntexture.png^[makealpha:255,0,255)", + t.."^("..t.."^mcl_stairs_turntexture.png^[transformR270^[makealpha:255,0,255)", + t + } + inner_tiles = { + t.."^("..t.."^[transformR90^(mcl_stairs_turntexture.png^[transformR180)^[makealpha:255,0,255)", + t.."^("..t.."^[transformR270^(mcl_stairs_turntexture.png^[transformR90)^[makealpha:255,0,255)", + t + } + elseif stairtiles == nil or stairtiles == "default" then outer_tiles = node_def.tiles inner_tiles = node_def.tiles + else + outer_tiles = stairtiles[1] + inner_tiles = stairtiles[2] end local outer_groups = table.copy(node_def.groups) outer_groups.not_in_creative_inventory = 1 diff --git a/mods/ITEMS/mcl_stairs/register.lua b/mods/ITEMS/mcl_stairs/register.lua index 1830a455c3..8311d14bf6 100644 --- a/mods/ITEMS/mcl_stairs/register.lua +++ b/mods/ITEMS/mcl_stairs/register.lua @@ -3,21 +3,6 @@ -- slabs actually take slightly longer to be dug than their stair counterparts. -- Note sure if it is a good idea to preserve this oddity. -local function make_corner_texture(subname) - local t = minetest.registered_nodes["mcl_core:"..subname].tiles[1] - return { - { - t.."^("..t.."^[transformR90^mcl_stairs_turntexture.png^[makealpha:255,0,255)", - t.."^("..t.."^mcl_stairs_turntexture.png^[transformR270^[makealpha:255,0,255)", - t - }, - { - t.."^("..t.."^[transformR90^(mcl_stairs_turntexture.png^[transformR180)^[makealpha:255,0,255)", - t.."^("..t.."^[transformR270^(mcl_stairs_turntexture.png^[transformR90)^[makealpha:255,0,255)", - t - } - } -end local woods = { { "wood", "default_wood.png", "Oak Wood Stairs", "Oak Wood Slab", "Double Oak Wood Slab" }, { "junglewood", "default_junglewood.png", "Jungle Wood Stairs", "Jungle Wood Slab", "Double Jungle Wood Slab" }, @@ -35,7 +20,7 @@ for w=1, #woods do wood[3], mcl_sounds.node_sound_wood_defaults(), 2, - make_corner_texture(wood[1])) + "woodlike") mcl_stairs.register_slab(wood[1], "mcl_core:"..wood[1], {handy=1,axey=1, flammable=3,wood_slab=1, material_wood=1}, {wood[2]},