Page 1 of 1

facedir during minetest.env:add_node

PostPosted: Thu Mar 29, 2012 13:15
by bgsmithjr
How do you use facedir when using minetest.env:add_node?

PostPosted: Thu Mar 29, 2012 14:27
by sfan5
minetest.env:add_node({x=1,y=2,z=3},{name="whatever",param2=2})

PostPosted: Thu Mar 29, 2012 15:44
by bgsmithjr
Thanks.

PostPosted: Thu Mar 29, 2012 18:47
by bgsmithjr
minetest.env:add_node( pos, { name = 'beds:blue_top', param2=2} ) doesn't work is still faces to the x coordinate of position

PostPosted: Thu Mar 29, 2012 18:50
by sfan5
bgsmithjr wrote:minetest.env:add_node( pos, { name = 'beds:blue_top', param2=2} ) doesn't work is still faces to the x coordinate of position

Try param1 or another value

PostPosted: Sat Jun 30, 2012 01:36
by tonyka
I've been trying ...
and it works, but I can not work with objects type nodebox ...
I guess Ahun not developed entirely these objects ...
know any way to do this?
thanks

sorry for my bad English ...

PostPosted: Sat Jun 30, 2012 13:03
by neo
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
paramtype = "light",
paramtype2 = "facedir",

PostPosted: Sat Jun 30, 2012 13:25
by tonyka
so I have it but does not work ....
My code is as follows ...

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
minetest.register_node("3dforniture:toilet", {
    description = 'Toilet',
    tiles = {
        "forniture_marble.png",
        "forniture_marble.png",
        "forniture_marble_s1.png",
        "forniture_marble_s1.png",
        "forniture_marble_s2.png",
        "forniture_marble_s2.png",
    },
    drawtype = "nodebox",
    sunlight_propagates = true,
    paramtype = 'light',
    paramtype2 = 'facedir',
    node_box = {
        type = "fixed",
        fixed = {
            {-0.2,-0.5,-0.2, 0.2,-0.45,0.5},
            {-0.1,-0.45,-0.1, 0.1,0,0.5},
            {-0.3,-0.2,-0.3, 0.3,0,0.35},
            {-0.25,0,-0.25, 0.25,0.05,0.25},
            {-0.3,0,0.3, 0.3,0.4,0.5},
            {-0.05,0.4,0.35, 0.05,0.45,0.45},
        },
    },
    drop = "3dforniture:toilet",
    groups = {cracky=2,}
   
})

minetest.register_node("3dforniture:toilet_open", {
    description = 'Toilet',
    tiles = {
        "forniture_marble_top_toilet.png",
        "forniture_marble.png",
        "forniture_marble_sb1.png",
        "forniture_marble_sb1.png",
        "forniture_marble_sb2.png",
        "forniture_marble_sb2.png",
    },
    drawtype = "nodebox",
    sunlight_propagates = true,
    paramtype = 'light',
    paramtype2 = 'facedir',
    node_box = {
        type = "fixed",
        fixed = {
            {-0.2,-0.5,-0.2, 0.2,-0.45,0.5},
            {-0.1,-0.45,-0.1, 0.1,-0.2,0.5},
            {-0.1,-0.2,0.3, 0.1,0,0.5},
            {-0.3,-0.2,0.1, 0.3,0,0.35},
            {-0.3,-0.2,-0.3, -0.1,-0.15,0.1},
            {-0.1,-0.2,-0.3, 0.1,-0.15,-0.1},
            {0.1,-0.2,-0.3, 0.3,-0.15,0.1},
            {-0.3,-0.15,-0.3, -0.2,0,0.1},
            {-0.2,-0.15,-0.3, 0.2,0,-0.2},
            {0.2,-0.15,-0.3, 0.3,0,0.1},
            {-0.25,0,0.2, 0.25,0.5,0.25},
            {-0.3,0,0.3, 0.3,0.4,0.5},

        },
    },
    drop = "3dforniture:toilet",
    groups = {cracky=2,}
})
-----------------------------------------------------------------
local on_toilet_puncher = function (pos, node, puncher)
    if node.name == '3dforniture:toilet' then
        minetest.env:add_node({x=1,y=2,z=3}, {name="3dforniture:toilet_open", param2=2 })
        nodeupdate(pos)
    elseif node.name == '3dforniture:toilet_open' then
        minetest.env:add_node({x=1,y=2,z=3}, {name="3dforniture:toilet", param2=2 })
        nodeupdate(pos)
    end
end

minetest.register_on_punchnode(on_toilet_puncher)

PostPosted: Sat Jun 30, 2012 14:29
by neo
" not ', same for light. : )

PostPosted: Sat Jun 30, 2012 17:25
by tonyka
neo wrote:" not ', same for light. : )

sorry for keep asking, the closest thing I've done has been "basic" in my ZX Spectrum ...

then would it be?

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
minetest.env: add_node ({x = 1, y = 2, z = 3}, {name = "3dforniture: toilet_open", param = 1, param2 = 2})


this does not work, as I do? some example if possible?
thanks ...

PostPosted: Sun Jul 01, 2012 00:08
by neo
Nodes
------
Nodes are the bulk data of the world: cubes and other things that take the
space of a cube. Huge amounts of them are handled efficiently, but they
are quite static.

The definition of a node is stored and can be accessed by name in
minetest.registered_nodes[node.name]
See "Registered definitions of stuff".

Nodes are passed by value between Lua and the engine.
They are represented by a table:
{name="name", param1=num, param2=num}

param1 and param2 are 8 bit and 4 bit integers, respectively. The engine
uses them for certain automated functions. If you don't use these
functions, you can use them to store arbitrary values.

The functions of param1 and param2 are determined by certain fields in the
node definition:
param1 is reserved for the engine when paramtype != "none":
paramtype = "light"
^ The value stores light with and without sun in it's
upper and lower 4 bits.
param2 is reserved for the engine when any of these are used:
liquidtype == "flowing"
^ The level and some flags of the liquid is stored in param2
drawtype == "flowingliquid"
^ The drawn liquid level is read from param2
drawtype == "torchlike"
drawtype == "signlike"
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().



Note the == it's important.

Everything is the /doc/lua_api.txt

Great document, tx to celeron55 who wrote this goldmine :)

PostPosted: Sun Jul 01, 2012 00:18
by tonyka
thanks! I'll try :D

PostPosted: Fri Sep 13, 2013 23:52
by leetelate
thanks from me too now

the most very basic facedirs:
0 is moving x-1
1 is moving z+1
2 is moving x+1
3 is moving z-1

source: had to test it - the doc is minetest.facedir_from_dir - it returns facedir from a 3d dir