Page 1 of 1

how to change the orientation of a door

PostPosted: Sun Jan 17, 2016 13:48
by Smitje
I found i can place a door with something like:

Code: Select all
...
local vi = area:index(locx, starty, locz)
data[vi] = minetest.get_content_id("doors:door_wood_b_1")
local vi = area:index(locx, starty+i -1, locz)
data[vi] = minetest.get_content_id("doors:door_wood_t_1")
...


But how do I change the orientation?

Cheers Smitje

Re: how to change the orientation of a door

PostPosted: Tue Jan 19, 2016 17:52
by Krock
Untested:
Code: Select all
local param2 = vm:get_param2_data()

...
local rotation = minetest.dir_to_facedir({x=1,y=0,z=0})
local vi = area:index(locx, starty, locz)
data[vi] = minetest.get_content_id("doors:door_wood_b_1")
param2[vi] = rotation

vi = area:index(locx, starty+ i - 1, locz)
data[vi] = minetest.get_content_id("doors:door_wood_t_1")
param2[vi] = rotation
...

vm:set_param2_data(param2)

Notice, the nodes must have paramtype2 set to "facedir" in its node definition.

Re: how to change the orientation of a door

PostPosted: Wed Jan 20, 2016 21:41
by Smitje
Hi Krock,
Thanks for your reply,

I'm testing it on a sign first. It works but I don't fully understand the results.

The sign has paramtype2 set to "wallmounted"
I've tried the following direction with the results listed.

Code: Select all
    -- local rotation = minetest.dir_to_facedir({x=1,y=0,z=0}) --sign facing up
    -- local rotation = minetest.dir_to_facedir({x=0,y=1,z=0}) -- same result as default sign floating facing down
    -- local rotation = minetest.dir_to_facedir({x=0,y=0,z=1}) -- same result as default
    -- local rotation = minetest.dir_to_facedir({x=-1,y=0,z=0}) -- sign facing east
    -- local rotation = minetest.dir_to_facedir({x=0,y=0,z=-1}) -- sign facing west
    local rotation = minetest.dir_to_facedir({x=0,y=-1,z=0})-- same result as default


Who can shed some light?

I found this description in "lua_api.txt"
but it does not explain what the input vector for dir_to_facedir should be.

Code: Select all
    paramtype2 == "wallmounted"
    ^ The rotation of the node is stored in param2. You can make this value
      by using minetest.dir_to_wallmounted().
    paramtype2 == "facedir"
    ^ The rotation of the node is stored in param2. Furnaces and chests are
      rotated this way. Can be made by using minetest.dir_to_facedir().
      Values range 0 - 23
      facedir modulo 4 = axisdir
      0 = y+    1 = z+    2 = z-    3 = x+    4 = x-    5 = y-
      facedir's two less significant bits are rotation around the axis