diff options
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/game/falling.lua | 11 | ||||
| -rw-r--r-- | builtin/game/item.lua | 6 | ||||
| -rw-r--r-- | builtin/game/item_s.lua | 25 |
3 files changed, 39 insertions, 3 deletions
diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index d5727f2a7..01a7d60b8 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -161,7 +161,16 @@ core.register_entity(":__builtin:falling_node", { local fdir = node.param2 % 32 % 24 -- Get rotation from a precalculated lookup table local euler = facedir_to_euler[fdir + 1] - self.object:set_rotation(euler) + if euler then + self.object:set_rotation(euler) + end + elseif (def.paramtype2 == "4dir" or def.paramtype2 == "color4dir") then + local fdir = node.param2 % 4 + -- Get rotation from a precalculated lookup table + local euler = facedir_to_euler[fdir + 1] + if euler then + self.object:set_rotation(euler) + end elseif (def.drawtype ~= "plantlike" and def.drawtype ~= "plantlike_rooted" and (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted" or def.drawtype == "signlike")) then local rot = node.param2 % 8 diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 00601c68c..af3fcb645 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -205,7 +205,9 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2, newnode.param2 = core.dir_to_wallmounted(dir) -- Calculate the direction for furnaces and chests and stuff elseif (def.paramtype2 == "facedir" or - def.paramtype2 == "colorfacedir") and not param2 then + def.paramtype2 == "colorfacedir" or + def.paramtype2 == "4dir" or + def.paramtype2 == "color4dir") and not param2 then local placer_pos = placer and placer:get_pos() if placer_pos then local dir = vector.subtract(above, placer_pos) @@ -225,6 +227,8 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2, color_divisor = 8 elseif def.paramtype2 == "colorfacedir" then color_divisor = 32 + elseif def.paramtype2 == "color4dir" then + color_divisor = 4 elseif def.paramtype2 == "colordegrotate" then color_divisor = 32 end diff --git a/builtin/game/item_s.lua b/builtin/game/item_s.lua index a51cd0a1c..ac1090d63 100644 --- a/builtin/game/item_s.lua +++ b/builtin/game/item_s.lua @@ -92,6 +92,26 @@ function core.facedir_to_dir(facedir) return facedir_to_dir[facedir_to_dir_map[facedir % 32]] end +function core.dir_to_fourdir(dir) + if math.abs(dir.x) > math.abs(dir.z) then + if dir.x < 0 then + return 3 + else + return 1 + end + else + if dir.z < 0 then + return 2 + else + return 0 + end + end +end + +function core.fourdir_to_dir(fourdir) + return facedir_to_dir[facedir_to_dir_map[fourdir % 4]] +end + function core.dir_to_wallmounted(dir) if math.abs(dir.y) > math.max(math.abs(dir.x), math.abs(dir.z)) then if dir.y < 0 then @@ -137,7 +157,8 @@ end function core.is_colored_paramtype(ptype) return (ptype == "color") or (ptype == "colorfacedir") or - (ptype == "colorwallmounted") or (ptype == "colordegrotate") + (ptype == "color4dir") or (ptype == "colorwallmounted") or + (ptype == "colordegrotate") end function core.strip_param2_color(param2, paramtype2) @@ -146,6 +167,8 @@ function core.strip_param2_color(param2, paramtype2) end if paramtype2 == "colorfacedir" then param2 = math.floor(param2 / 32) * 32 + elseif paramtype2 == "color4dir" then + param2 = math.floor(param2 / 4) * 4 elseif paramtype2 == "colorwallmounted" then param2 = math.floor(param2 / 8) * 8 elseif paramtype2 == "colordegrotate" then |
