Skip to content

Commit

Permalink
Stairs: Set world-aligned textures for all stairs and slabs
Browse files Browse the repository at this point in the history
Fix 'stair_images' code to avoid 'stair_images' being empty in some
situations.
Change stairs back to nodeboxes to make world-aligned textures work.
  • Loading branch information
paramat committed Nov 4, 2017
1 parent dbfe435 commit 9d9e9b6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 505 deletions.
9 changes: 0 additions & 9 deletions mods/stairs/README.txt
Expand Up @@ -7,12 +7,3 @@ Authors of source code
Originally by Kahrl <kahrl@gmx.net> (LGPL 2.1) and
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPL 2.1)
Various Minetest developers and contributors (LGPL 2.1)

Authors of media (models)
-------------------------
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC BY-SA 3.0):
stairs_stair.obj
GreenXenith (CC BY-SA 3.0)
stairs_stair_inner.obj stairs_stair_outer.obj


101 changes: 56 additions & 45 deletions mods/stairs/init.lua
Expand Up @@ -46,41 +46,40 @@ end
-- Node will be called stairs:stair_<subname>

function stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
stair_images[i] = {
name = image,
backface_culling = true,
align_style = "world",
}
elseif image.backface_culling == nil then -- override using any other value
else
stair_images[i] = table.copy(image)
stair_images[i].backface_culling = true
if stair_images[i].backface_culling == nil then
stair_images[i].backface_culling = true
end
if stair_images[i].align_style == nil then
stair_images[i].align_style = "world"
end
end
end
groups.stair = 1
minetest.register_node(":stairs:stair_" .. subname, {
description = description,
drawtype = "mesh",
mesh = "stairs_stair.obj",
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = groups,
sounds = sounds,
selection_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},
},
},
collision_box = {
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.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
},
},
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -144,11 +143,26 @@ local slab_trans_dir = {[0] = 8, 0, 2, 1, 3, 4}
-- Node will be called stairs:slab_<subname>

function stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
-- Set world-aligned textures
local slab_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
slab_images[i] = {
name = image,
align_style = "world",
}
else
slab_images[i] = table.copy(image)
if image.align_style == nil then
slab_images[i].align_style = "world"
end
end
end
groups.slab = 1
minetest.register_node(":stairs:slab_" .. subname, {
description = description,
drawtype = "nodebox",
tiles = images,
tiles = slab_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
Expand Down Expand Up @@ -280,43 +294,41 @@ end
-- Node will be called stairs:stair_inner_<subname>

function stairs.register_stair_inner(subname, recipeitem, groups, images, description, sounds)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
stair_images[i] = {
name = image,
backface_culling = true,
align_style = "world",
}
elseif image.backface_culling == nil then -- override using any other value
else
stair_images[i] = table.copy(image)
stair_images[i].backface_culling = true
if stair_images[i].backface_culling == nil then
stair_images[i].backface_culling = true
end
if stair_images[i].align_style == nil then
stair_images[i].align_style = "world"
end
end
end
groups.stair = 1
minetest.register_node(":stairs:stair_inner_" .. subname, {
description = description .. " Inner",
drawtype = "mesh",
mesh = "stairs_stair_inner.obj",
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = groups,
sounds = sounds,
selection_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},
},
},
collision_box = {
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},
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
{-0.5, 0.0, -0.5, 0.0, 0.5, 0.0},
},
},
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -358,41 +370,40 @@ end
-- Node will be called stairs:stair_outer_<subname>

function stairs.register_stair_outer(subname, recipeitem, groups, images, description, sounds)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
stair_images[i] = {
name = image,
backface_culling = true,
align_style = "world",
}
elseif image.backface_culling == nil then -- override using any other value
else
stair_images[i] = table.copy(image)
stair_images[i].backface_culling = true
if stair_images[i].backface_culling == nil then
stair_images[i].backface_culling = true
end
if stair_images[i].align_style == nil then
stair_images[i].align_style = "world"
end
end
end
groups.stair = 1
minetest.register_node(":stairs:stair_outer_" .. subname, {
description = description .. " Outer",
drawtype = "mesh",
mesh = "stairs_stair_outer.obj",
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = groups,
sounds = sounds,
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0, 0.5, 0.5},
},
},
collision_box = {
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},
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.0, 0.5, 0.5},
},
},
on_place = function(itemstack, placer, pointed_thing)
Expand Down
42 changes: 3 additions & 39 deletions mods/stairs/license.txt
Expand Up @@ -2,9 +2,9 @@ License of source code
----------------------

GNU Lesser General Public License, version 2.1
Copyright (C) 2011-2016 Kahrl <kahrl@gmx.net>
Copyright (C) 2011-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2012-2016 Various Minetest developers and contributors
Copyright (C) 2011-2017 Kahrl <kahrl@gmx.net>
Copyright (C) 2011-2017 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2012-2017 Various Minetest developers and contributors

This program is free software; you can redistribute it and/or modify it under the terms
of the GNU Lesser General Public License as published by the Free Software Foundation;
Expand All @@ -14,39 +14,3 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details:
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html


Licenses of media (models)
--------------------------

Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Copyright (C) 2015-2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
Copyright (C) 2017 GreenXenith

You are free to:
Share — copy and redistribute the material in any medium or format.
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

Attribution — You must give appropriate credit, provide a link to the license, and
indicate if changes were made. You may do so in any reasonable manner, but not in any way
that suggests the licensor endorses you or your use.

ShareAlike — If you remix, transform, or build upon the material, you must distribute
your contributions under the same license as the original.

No additional restrictions — You may not apply legal terms or technological measures that
legally restrict others from doing anything the license permits.

Notices:

You do not have to comply with the license for elements of the material in the public
domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary
for your intended use. For example, other rights such as publicity, privacy, or moral
rights may limit how you use the material.

For more details:
http://creativecommons.org/licenses/by-sa/3.0/
115 changes: 0 additions & 115 deletions mods/stairs/models/stairs_stair.obj

This file was deleted.

0 comments on commit 9d9e9b6

Please sign in to comment.