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

Post Reply
User avatar
super_tnt
Member
Posts: 21
Joined: Mon Sep 02, 2013 17:56

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

by super_tnt » Post

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

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.
Last edited by super_tnt on Wed Sep 04, 2013 20:14, edited 1 time in total.

User avatar
sfan5
Moderator
Posts: 3946
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

You can create screenshots with F12
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
super_tnt
Member
Posts: 21
Joined: Mon Sep 02, 2013 17:56

by super_tnt » Post

Thanks for that, I usually hold alt+prtsc which gives the window but I'll use f12 in future.

User avatar
hoodedice
Member
Posts: 1374
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

by hoodedice » Post

I think there is already a mod like this...
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

Jordach
Member
Posts: 4527
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach
Location: Blender Scene

by Jordach » Post

I cropped the image for you:
Image
viewtopic.php?f=10&t=19056 Solar Plains Dev Server

User avatar
Mossmanikin
Member
Posts: 599
Joined: Sun May 19, 2013 16:26
Location: where we don't speak english.

by Mossmanikin » Post

Thanks for sharing this, I can really use the code for my plant mods :)

Noob 4 life!
My stuff

User avatar
super_tnt
Member
Posts: 21
Joined: Mon Sep 02, 2013 17:56

by super_tnt » Post

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.

User avatar
super_tnt
Member
Posts: 21
Joined: Mon Sep 02, 2013 17:56

by super_tnt » Post

Jordach wrote:I cropped the image for you:
~~~~~~~

Thank you for that

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests