Page 1 of 1

Not sure what to call this one: Destroying all cactuses in a column

PostPosted: Wed Sep 04, 2013 17:02
by super_tnt
So, I know I shouldn't compare this game to minecraft but a simple thing that I was missing was cactuses being destroyed when you dig the bottom one, so I added it to this game, It could be added to trees but it should use the axe's durability.
Image
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("default:cactus", {
    description = "Cactus",
    tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
    is_ground_content = true,
    groups = {snappy=1,choppy=3,flammable=2},
    sounds = default.node_sound_wood_defaults(),
    after_destruct = function(pos,oldnode)
        local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
        if node.name == "default:cactus" then
            minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
            minetest.add_item(pos,"default:cactus")
        end
    end,
})


Edit: source is included, replace the same cactus bit of could in the nodes.lua file in the default folder.

PostPosted: Wed Sep 04, 2013 17:20
by sfan5
You can create screenshots with F12

PostPosted: Wed Sep 04, 2013 17:29
by super_tnt
Thanks for that, I usually hold alt+prtsc which gives the window but I'll use f12 in future.

PostPosted: Wed Sep 04, 2013 17:40
by hoodedice
I think there is already a mod like this...

PostPosted: Wed Sep 04, 2013 19:11
by Jordach
I cropped the image for you:
Image

PostPosted: Wed Sep 04, 2013 19:56
by Mossmanikin
Thanks for sharing this, I can really use the code for my plant mods :)

PostPosted: Wed Sep 04, 2013 20:13
by super_tnt
Mossmanikin wrote:Thanks for sharing this, I can really use the code for my plant mods :)


No problems, I get quite happy when things like this work.

You see there is no need to cycle through each cactus block and destroy it. Alls we have to do is add a little bit of code so that when it is destroyed it triggers the next one to get destroyed. This process is repeated until it can't trigger the next block because it's not a cactus.

PostPosted: Wed Sep 04, 2013 20:14
by super_tnt
Jordach wrote:I cropped the image for you:

~~~~~~~

Thank you for that