Page 1 of 1

[solved] minetest.dig_node and digger parameter

PostPosted: Wed Jun 01, 2016 16:49
by christian99
Hey guys,
I'm first time trying to mod minetest, but have a little problem:
I want to pass the digger parameter to minetest.dig_node, but it doesn't have any effect.
The Debug.txt shows "2016-06-01 18:02:18: ACTION[Server]: digs default:tree at (8,19,-75)"
the result is, that the node is removed, but I don't get the resources.
When I dig a node manually, I'll get "ACTION[Server]: singleplayer digs moretrees:birch_leaves at (-245,22,-71)"

I'm in on_dig and using the digger which is passed as parameter.
What exactly do I need to pass to dig_node, so that it works. Also the node parameter seems to have no effect. What should i pass here? I would expect, that the position is enough.

Re: minetest.dig_node and digger parameter

PostPosted: Wed Jun 01, 2016 17:53
by sofar
you need to pass the player object.

If you show your code we can see what is wrong with it.

Re: minetest.dig_node and digger parameter

PostPosted: Wed Jun 01, 2016 18:11
by christian99
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 radius = 2

minetest.register_on_dignode(
   function(pos, oldnode, digger)
      if minetest.get_node_group( oldnode.name, "tree" ) ~= 0 then
         
         local leaf_node = minetest.find_node_near( pos, 3, { "group:leaves" } )
         while leaf_node ~= nil do
            minetest.dig_node( leaf_node, nil, digger )
            leaf_node = minetest.find_node_near( pos, radius, { oldnode.name } )
         end
         
         local tree_node = minetest.find_node_near( pos, 3, { "group:tree" } )
         while tree_node ~= nil do
            minetest.dig_node( tree_node, nil, digger )
            tree_node = minetest.find_node_near( pos, radius, { oldnode.name } )
         end
      end
   end
)


So , where do i get a player object? the digger parameter for on_dignode is obviously not the right one...

Re: minetest.dig_node and digger parameter

PostPosted: Thu Jun 02, 2016 04:56
by sofar
https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L2031

`minetest.dig_node(pos)`

it doesn't allow for a digger or node parameter. You have to handle the drop yourself.

Re: minetest.dig_node and digger parameter

PostPosted: Thu Jun 02, 2016 07:57
by christian99

Re: minetest.dig_node and digger parameter

PostPosted: Thu Jun 02, 2016 15:36
by sofar
christian99 wrote:This means http://dev.minetest.net/minetest.dig_node is outdated?


Yes, it is. I've updated the wiki page to reflect this.

Re: minetest.dig_node and digger parameter

PostPosted: Thu Jun 02, 2016 21:11
by christian99
Ok, thx for looking into this.
BTW: I accomplished what I wanted with minetest.node_dig