Page 1 of 1

Rotation of place_schematics

PostPosted: Sun Sep 20, 2015 23:46
by Exilyth
Hi.

When the rotation parameter of minetest.place_schematic(...) is not "0", what point is the schematic rotated around?

The dev wiki is a bit quiet on the topic:
http://dev.minetest.net/minetest.place_schematic

I've got the rotation working so that the schematic points in the direction the player is facing, but there seems to be a direction dependent offset, even though I'm using the unmodified player position for placing the schematic.
What I mean is that e.g. facing down +X, part of the schematic is placed behind me.
Using "0" for rotation, the position which was pos1 in [World Edit] is placed where I stand.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
-- helper - finds the rotation value for a certain direction
function dir_to_rotation(p_dir)
   if p_dir.x == 0 and p_dir.z > 0 then
      return "0"
   end
   if p_dir.x == 0 and p_dir.z < 0 then
      return "180"
   end
   if p_dir.x > 0 and p_dir.z == 0 then
      return "90"
   end
   if p_dir.x < 0 and p_dir.z == 0 then
      return "270"
   end
   return "0"
end

-- I'm using the function like this
minetest.place_schematic(player:getpos(), "mymod/schematic.mts", dir_to_rotation(player:get_look_dir()), nil, true)

Re: Rotation of place_schematics

PostPosted: Mon Sep 21, 2015 16:58
by paramat
Schematic rotation is around the vertical axis (+Y) only.

Re: Rotation of place_schematics

PostPosted: Fri Sep 25, 2015 22:16
by Exilyth
I know that rotation is only about +Y, but around which point of the schematic?

e.g. if I have a schematic which looks like this from above (let X = default:dirt or something):
1XXXXXX
XXX2XXX
XXXXXX3

What would the schematic look like when placed with a rotation of "0", "90", "180", 270"?

Re: Rotation of place_schematics

PostPosted: Sat Sep 26, 2015 13:56
by Don
The schematic is placed at the pos you set. It places north east. When you rotate the schematic it still places the same direction.
If you have a schematic that is 5 x 10, at 0 rotation it would place 5 nodes north of pos and 10 east.
if you rotate it 90 degrees it would place 10 north and 5 east.

Hope that is clear. It always places north east no matter the rotation.

Re: Rotation of place_schematics

PostPosted: Sat Sep 26, 2015 19:28
by paramat
Ah i see. Yes if you don't have any 'place_center_x/z' flags set it is always North East (+Z +X) of the spawn pos, with the spawn pos at it's SE (-Z -X) corner.

Re: Rotation of place_schematics

PostPosted: Mon Sep 28, 2015 03:22
by Sokomine
Or use my handle_schematics mod if you want to spawn schematics that always face the player, no matter what direction the player faces.