mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 23:42:59 +00:00
orientation: refactor a bit, docs
This commit is contained in:
parent
d49f6d2131
commit
d29b037675
1 changed files with 44 additions and 35 deletions
|
@ -29,13 +29,13 @@ end
|
|||
--
|
||||
-- Ref <https://github.com/12Me21/screwdriver2/blob/master/init.lua#L75-L79> and <https://forum.minetest.net/viewtopic.php?p=73195&sid=1d2d2e4e76ce2ef9c84646481a4b84bc#p73195>
|
||||
-- @namespace worldeditadditions_core.orientation
|
||||
local orientation = {
|
||||
|
||||
--- Facedir: lower 5 bits used for direction, 0 - 23
|
||||
-- @param param2 number `param2` value to rotate.
|
||||
-- @param axis string The name of the axis to rotate around. Valid values: `x`, `y`, `z`
|
||||
-- @param amount The number of radians to rotate around the given `axis`. Only right angles are supported (i.e. 90° increments). Any value that isn't a 90° increment will be **rounded**!
|
||||
-- @returns number A new param2 value that is rotated the given number of degrees around the given `axis`
|
||||
facedir = function(param2, axis, amount_rad)
|
||||
function facedir(param2, axis, amount_rad)
|
||||
local amount = convert_normalise_rad(amount_rad)
|
||||
print("DEBUG:core/orientation:facedir AMOUNT rad "..tostring(amount_rad).." norm "..tostring(amount))
|
||||
local facedir = param2 % 32
|
||||
|
@ -49,9 +49,14 @@ local orientation = {
|
|||
end
|
||||
end
|
||||
return param2
|
||||
end,
|
||||
-- Wallmounted: lower 3 bits used, 0 - 5
|
||||
wallmounted = function(param2, axis, amount_rad)
|
||||
end
|
||||
|
||||
--- Wallmounted: lower 3 bits used, 0 - 5
|
||||
-- @param param2 number `param2` value to rotate.
|
||||
-- @param axis string The name of the axis to rotate around. Valid values: `x`, `y`, `z`
|
||||
-- @param amount The number of radians to rotate around the given `axis`. Only right angles are supported (i.e. 90° increments). Any value that isn't a 90° increment will be **rounded**!
|
||||
-- @returns number A new param2 value that is rotated the given number of degrees around the given `axis`
|
||||
function wallmounted(param2, axis, amount_rad)
|
||||
local amount = convert_normalise_rad(amount_rad)
|
||||
print("DEBUG:core/orientation:wallmounted AMOUNT rad " .. tostring(amount_rad) .. " norm " .. tostring(amount))
|
||||
|
||||
|
@ -63,10 +68,14 @@ local orientation = {
|
|||
end
|
||||
return param2
|
||||
end
|
||||
}
|
||||
|
||||
local orientation = {
|
||||
facedir = facedir,
|
||||
wallmounted = wallmounted,
|
||||
-- From the original codebase (linked above):
|
||||
--orientation.colorfacedir = orientation.facedir
|
||||
--orientation.colorwallmounted = orientation.wallmounted
|
||||
--colorfacedir = facedir,
|
||||
--colorwallmounted = wallmounted
|
||||
-- ...we'll need to know this later
|
||||
}
|
||||
|
||||
return orientation
|
||||
|
|
Loading…
Reference in a new issue