Page 1 of 1

How do you get the drawtype of a node?

PostPosted: Thu Apr 12, 2012 21:19
by lkjoel
I'm trying to figure out some code that finds the drawtype of a node. How would I go about doing this?

PostPosted: Thu Apr 12, 2012 21:31
by Jeija
You cannot get the drawtype of a node itself (as far as I know). You can only get some other parameters, e.g. if it is flammable / walkable.

PostPosted: Thu Apr 12, 2012 21:34
by lkjoel
ok, I'll have to edit the modding API then...

PostPosted: Thu Apr 12, 2012 22:08
by celeron55
Hell, people are always giving wrong answers on this forum...

Yes you can find the drawtype of a node; everything given to minetest.register_node is put into the minetest.registered_nodes table.

Thus: (not tested)
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
local function get_node_drawtype(nodename)
    if not minetest.registered_nodes[nodename] then
        return ""
    end
    return minetest.registered_nodes[nodename].drawtype
end

PostPosted: Thu Apr 12, 2012 23:03
by lkjoel
thanks! It works!

PostPosted: Fri Apr 13, 2012 05:29
by Jeija
Sorry, I didn't know that. Could you add some information about this to the lua_api.txt (if there is none yet)? Like "you can acces the information in a node simply by writing node.*.
Once Iw tried to get e.g. the texture of a node, back then it didn't work at all.