Page 1 of 1

Cant use on_placenode and on_destruct at same time?

PostPosted: Tue Jan 15, 2013 19:24
by FosJonas
Hello,

I'm trying to make a Mod for Minetest, but I already got a Problem:

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("test:test", {
    description = "test",
      tiles = {"default_gravel.png"},
    paramtype2 = "facedir",
    groups = {cracky=3, stone=1},
   power = true,
   
 
   
   after_destruct = function(pos,oldnode)
    return 0
   end   

   after_place_node = function(pos, placer)
    return 0
    end
   
    })


This code will cause a error (expected to close '{' at line 48 near 'after place node' ).
But I dont understand why, if I use just after_place_node or just after_destruct it works fine.
Cant I use both function in one Node?

I would be happy about every help.

PostPosted: Tue Jan 15, 2013 19:34
by PilzAdam
Since after_destruct and after_place_node are regular fields in the table you have to seperate them with commas:
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("test:test", {
    description = "test",
    tiles = {"default_gravel.png"},
    paramtype2 = "facedir",
    groups = {cracky=3, stone=1},
    power = true,

    after_destruct = function(pos,oldnode)
        return 0
    end,

    after_place_node = function(pos, placer)
        return 0
    end,

})

PostPosted: Tue Jan 15, 2013 19:35
by glomie
you need a comma after the end before after_place_node

PostPosted: Tue Jan 15, 2013 19:47
by FosJonas
Wow thanks for the Ultra fast help!

Now it works well.