Stairs: Big simplification of slabs combination
authorAuke Kok <sofar@foo-projects.org>
Mon, 25 Jan 2016 12:45:25 +0000 (13:45 +0100)
committerparamat <mat.gregory@virginmedia.com>
Wed, 14 Sep 2016 05:01:04 +0000 (06:01 +0100)
commitb848e35ca59c9eea3dbe3df87cb14d6bfea93f9a
tree38fe04c5cc3ce6a3da30e7a3115e97498c8d4d3f
parent0cbb516ae2a8ec7acf6aa968715f3c1aa32a8f5b
Stairs: Big simplification of slabs combination

Combine slabs if identical based on orientations using a simple lookup
table if the nodes are identical.

Otherwise relies on place_node() to place the node, which properly
handles rotation compared to adjacent nodes already, and can orient
based on look_dir as well.

Initial slabs placed are oriented based on (1) the orientation of
the pointed "face" (assumes nodes are cubic, of course), and uses
the player look direction to orient the node n/e/w/s if the slab
is horizontal or upside-down. If placed against a vertical face,
the slab is placed against the face without rotation around the axis
perpendicular to that vertical face. This allows upside down placement
and vertical placement without screwdriver.

If a slab is placed on top of an upside down slab, or below a normally
placed slab, the rotation is inverted so that no "floating" slab
is created.

Largely based on kilbith's #807 PR. Slab combining and place_node()
usage by sofar.

Since this relies entirely on `on_place` mechanics, this fails to
combine slabs into a plain node if the space *above* is occupied.
This is unavoidable due to the fact that on_place() happens after
the checks required to see if pointed_thing.above is empty or not.
mods/stairs/init.lua