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)