From 39761fc9c11f20ad30566343fc653c9322469b73 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:56:27 -0400 Subject: [PATCH] niklp suggestion --- homedecor_seating/init.lua | 66 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/homedecor_seating/init.lua b/homedecor_seating/init.lua index 717a4bab..4725e4ee 100644 --- a/homedecor_seating/init.lua +++ b/homedecor_seating/init.lua @@ -94,6 +94,39 @@ minetest.register_entity("homedecor_seating:seat", { end, }) +--we only care about 4 rotations, but just in case someone worldedits, etc - do something other than crash +--radians are stupid, using degrees and then converting +local p2r = { + 0*math.pi/180, + 0*math.pi/180, --correct + 180*math.pi/180, --correct + 90*math.pi/180, --correct + 270*math.pi/180, --correct + 0*math.pi/180, + 0*math.pi/180, + 0*math.pi/180, +} +p2r[0] = p2r[1] + +local p2r_sofa = { + 0*math.pi/180, + 90*math.pi/180, --correct + 270*math.pi/180, --correct + 180*math.pi/180, --correct + 0*math.pi/180, --correct + 0*math.pi/180, + 0*math.pi/180, + 0*math.pi/180, +} +p2r_sofa[0] = p2r_sofa[1] + +local p2r_facedir = { + [0] = 180*math.pi/180, + [1] = 90*math.pi/180, + [2] = 0*math.pi/180, + [3] = 270*math.pi/180, +} + function lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, seats) if not clicker:is_player() then return itemstack @@ -145,39 +178,6 @@ function lrfurn.sit(pos, node, clicker, itemstack, pointed_thing, seats) --seat the player clicker:set_pos(sit_pos) - --we only care about 4 rotations, but just in case someone worldedits, etc - do something other than crash - --radians are stupid, using degrees and then converting - local p2r = { - 0*math.pi/180, - 0*math.pi/180, --correct - 180*math.pi/180, --correct - 90*math.pi/180, --correct - 270*math.pi/180, --correct - 0*math.pi/180, - 0*math.pi/180, - 0*math.pi/180, - } - p2r[0] = p2r[1] - - local p2r_sofa = { - 0*math.pi/180, - 90*math.pi/180, --correct - 270*math.pi/180, --correct - 180*math.pi/180, --correct - 0*math.pi/180, --correct - 0*math.pi/180, - 0*math.pi/180, - 0*math.pi/180, - } - p2r_sofa[0] = p2r_sofa[1] - - local p2r_facedir = { - [0] = 180*math.pi/180, - [1] = 90*math.pi/180, - [2] = 0*math.pi/180, - [3] = 270*math.pi/180, - } - local entity = minetest.add_entity(sit_pos, "homedecor_seating:seat") if not entity then return itemstack end --catch for when the entity fails to spawn just in case