Rotation of place_schematics

Exilyth
Member
 
Posts: 60
Joined: Sun Jul 28, 2013 18:46

Rotation of place_schematics

by Exilyth » Sun Sep 20, 2015 23:46

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)
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Rotation of place_schematics

by paramat » Mon Sep 21, 2015 16:58

Schematic rotation is around the vertical axis (+Y) only.
 

Exilyth
Member
 
Posts: 60
Joined: Sun Jul 28, 2013 18:46

Re: Rotation of place_schematics

by Exilyth » Fri Sep 25, 2015 22:16

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"?
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Rotation of place_schematics

by Don » Sat Sep 26, 2015 13:56

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.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Rotation of place_schematics

by paramat » Sat Sep 26, 2015 19:28

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.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Rotation of place_schematics

by Sokomine » Mon Sep 28, 2015 03:22

Or use my handle_schematics mod if you want to spawn schematics that always face the player, no matter what direction the player faces.
A list of my mods can be found here.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 10 guests

cron