how to change the orientation of a door

Post Reply
Smitje
Member
Posts: 22
Joined: Wed Nov 14, 2012 20:42

how to change the orientation of a door

by Smitje » Post

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

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: how to change the orientation of a door

by Krock » Post

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.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Smitje
Member
Posts: 22
Joined: Wed Nov 14, 2012 20:42

Re: how to change the orientation of a door

by Smitje » Post

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

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests