Skip to content

Commit 9d9e9b6

Browse files
committedNov 4, 2017
Stairs: Set world-aligned textures for all stairs and slabs
Fix 'stair_images' code to avoid 'stair_images' being empty in some situations. Change stairs back to nodeboxes to make world-aligned textures work.
1 parent dbfe435 commit 9d9e9b6

File tree

6 files changed

+59
-505
lines changed

6 files changed

+59
-505
lines changed
 

Diff for: ‎mods/stairs/README.txt

-9
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,3 @@ Authors of source code
77
Originally by Kahrl <kahrl@gmx.net> (LGPL 2.1) and
88
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPL 2.1)
99
Various Minetest developers and contributors (LGPL 2.1)
10-
11-
Authors of media (models)
12-
-------------------------
13-
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC BY-SA 3.0):
14-
stairs_stair.obj
15-
GreenXenith (CC BY-SA 3.0)
16-
stairs_stair_inner.obj stairs_stair_outer.obj
17-
18-

Diff for: ‎mods/stairs/init.lua

+56-45
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,40 @@ end
4646
-- Node will be called stairs:stair_<subname>
4747

4848
function stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
49+
-- Set backface culling and world-aligned textures
4950
local stair_images = {}
5051
for i, image in ipairs(images) do
5152
if type(image) == "string" then
5253
stair_images[i] = {
5354
name = image,
5455
backface_culling = true,
56+
align_style = "world",
5557
}
56-
elseif image.backface_culling == nil then -- override using any other value
58+
else
5759
stair_images[i] = table.copy(image)
58-
stair_images[i].backface_culling = true
60+
if stair_images[i].backface_culling == nil then
61+
stair_images[i].backface_culling = true
62+
end
63+
if stair_images[i].align_style == nil then
64+
stair_images[i].align_style = "world"
65+
end
5966
end
6067
end
6168
groups.stair = 1
6269
minetest.register_node(":stairs:stair_" .. subname, {
6370
description = description,
64-
drawtype = "mesh",
65-
mesh = "stairs_stair.obj",
71+
drawtype = "nodebox",
6672
tiles = stair_images,
6773
paramtype = "light",
6874
paramtype2 = "facedir",
6975
is_ground_content = false,
7076
groups = groups,
7177
sounds = sounds,
72-
selection_box = {
73-
type = "fixed",
74-
fixed = {
75-
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
76-
{-0.5, 0, 0, 0.5, 0.5, 0.5},
77-
},
78-
},
79-
collision_box = {
78+
node_box = {
8079
type = "fixed",
8180
fixed = {
82-
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
83-
{-0.5, 0, 0, 0.5, 0.5, 0.5},
81+
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
82+
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
8483
},
8584
},
8685
on_place = function(itemstack, placer, pointed_thing)
@@ -144,11 +143,26 @@ local slab_trans_dir = {[0] = 8, 0, 2, 1, 3, 4}
144143
-- Node will be called stairs:slab_<subname>
145144

146145
function stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
146+
-- Set world-aligned textures
147+
local slab_images = {}
148+
for i, image in ipairs(images) do
149+
if type(image) == "string" then
150+
slab_images[i] = {
151+
name = image,
152+
align_style = "world",
153+
}
154+
else
155+
slab_images[i] = table.copy(image)
156+
if image.align_style == nil then
157+
slab_images[i].align_style = "world"
158+
end
159+
end
160+
end
147161
groups.slab = 1
148162
minetest.register_node(":stairs:slab_" .. subname, {
149163
description = description,
150164
drawtype = "nodebox",
151-
tiles = images,
165+
tiles = slab_images,
152166
paramtype = "light",
153167
paramtype2 = "facedir",
154168
is_ground_content = false,
@@ -280,43 +294,41 @@ end
280294
-- Node will be called stairs:stair_inner_<subname>
281295

282296
function stairs.register_stair_inner(subname, recipeitem, groups, images, description, sounds)
297+
-- Set backface culling and world-aligned textures
283298
local stair_images = {}
284299
for i, image in ipairs(images) do
285300
if type(image) == "string" then
286301
stair_images[i] = {
287302
name = image,
288303
backface_culling = true,
304+
align_style = "world",
289305
}
290-
elseif image.backface_culling == nil then -- override using any other value
306+
else
291307
stair_images[i] = table.copy(image)
292-
stair_images[i].backface_culling = true
308+
if stair_images[i].backface_culling == nil then
309+
stair_images[i].backface_culling = true
310+
end
311+
if stair_images[i].align_style == nil then
312+
stair_images[i].align_style = "world"
313+
end
293314
end
294315
end
295316
groups.stair = 1
296317
minetest.register_node(":stairs:stair_inner_" .. subname, {
297318
description = description .. " Inner",
298-
drawtype = "mesh",
299-
mesh = "stairs_stair_inner.obj",
319+
drawtype = "nodebox",
300320
tiles = stair_images,
301321
paramtype = "light",
302322
paramtype2 = "facedir",
303323
is_ground_content = false,
304324
groups = groups,
305325
sounds = sounds,
306-
selection_box = {
307-
type = "fixed",
308-
fixed = {
309-
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
310-
{-0.5, 0, 0, 0.5, 0.5, 0.5},
311-
{-0.5, 0, -0.5, 0, 0.5, 0},
312-
},
313-
},
314-
collision_box = {
326+
node_box = {
315327
type = "fixed",
316328
fixed = {
317-
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
318-
{-0.5, 0, 0, 0.5, 0.5, 0.5},
319-
{-0.5, 0, -0.5, 0, 0.5, 0},
329+
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
330+
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
331+
{-0.5, 0.0, -0.5, 0.0, 0.5, 0.0},
320332
},
321333
},
322334
on_place = function(itemstack, placer, pointed_thing)
@@ -358,41 +370,40 @@ end
358370
-- Node will be called stairs:stair_outer_<subname>
359371

360372
function stairs.register_stair_outer(subname, recipeitem, groups, images, description, sounds)
373+
-- Set backface culling and world-aligned textures
361374
local stair_images = {}
362375
for i, image in ipairs(images) do
363376
if type(image) == "string" then
364377
stair_images[i] = {
365378
name = image,
366379
backface_culling = true,
380+
align_style = "world",
367381
}
368-
elseif image.backface_culling == nil then -- override using any other value
382+
else
369383
stair_images[i] = table.copy(image)
370-
stair_images[i].backface_culling = true
384+
if stair_images[i].backface_culling == nil then
385+
stair_images[i].backface_culling = true
386+
end
387+
if stair_images[i].align_style == nil then
388+
stair_images[i].align_style = "world"
389+
end
371390
end
372391
end
373392
groups.stair = 1
374393
minetest.register_node(":stairs:stair_outer_" .. subname, {
375394
description = description .. " Outer",
376-
drawtype = "mesh",
377-
mesh = "stairs_stair_outer.obj",
395+
drawtype = "nodebox",
378396
tiles = stair_images,
379397
paramtype = "light",
380398
paramtype2 = "facedir",
381399
is_ground_content = false,
382400
groups = groups,
383401
sounds = sounds,
384-
selection_box = {
385-
type = "fixed",
386-
fixed = {
387-
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
388-
{-0.5, 0, 0, 0, 0.5, 0.5},
389-
},
390-
},
391-
collision_box = {
402+
node_box = {
392403
type = "fixed",
393404
fixed = {
394-
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
395-
{-0.5, 0, 0, 0, 0.5, 0.5},
405+
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
406+
{-0.5, 0.0, 0.0, 0.0, 0.5, 0.5},
396407
},
397408
},
398409
on_place = function(itemstack, placer, pointed_thing)

Diff for: ‎mods/stairs/license.txt

+3-39
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ License of source code
22
----------------------
33

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

99
This program is free software; you can redistribute it and/or modify it under the terms
1010
of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -14,39 +14,3 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
1414
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1515
See the GNU Lesser General Public License for more details:
1616
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
17-
18-
19-
Licenses of media (models)
20-
--------------------------
21-
22-
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
23-
Copyright (C) 2015-2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
24-
Copyright (C) 2017 GreenXenith
25-
26-
You are free to:
27-
Share — copy and redistribute the material in any medium or format.
28-
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
29-
The licensor cannot revoke these freedoms as long as you follow the license terms.
30-
31-
Under the following terms:
32-
33-
Attribution — You must give appropriate credit, provide a link to the license, and
34-
indicate if changes were made. You may do so in any reasonable manner, but not in any way
35-
that suggests the licensor endorses you or your use.
36-
37-
ShareAlike — If you remix, transform, or build upon the material, you must distribute
38-
your contributions under the same license as the original.
39-
40-
No additional restrictions — You may not apply legal terms or technological measures that
41-
legally restrict others from doing anything the license permits.
42-
43-
Notices:
44-
45-
You do not have to comply with the license for elements of the material in the public
46-
domain or where your use is permitted by an applicable exception or limitation.
47-
No warranties are given. The license may not give you all of the permissions necessary
48-
for your intended use. For example, other rights such as publicity, privacy, or moral
49-
rights may limit how you use the material.
50-
51-
For more details:
52-
http://creativecommons.org/licenses/by-sa/3.0/

Diff for: ‎mods/stairs/models/stairs_stair.obj

-115
This file was deleted.

Diff for: ‎mods/stairs/models/stairs_stair_inner.obj

-161
This file was deleted.

Diff for: ‎mods/stairs/models/stairs_stair_outer.obj

-136
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.