Simple Auto-Mining Block?

Post Reply
User avatar
JWinch
New member
Posts: 1
Joined: Wed Jul 03, 2013 14:19

Simple Auto-Mining Block?

by JWinch » Post

Hi my name is JWINCH and I am a 15 year old programmer that loves my RPi, Linux and computing.

A question I have is about making a simple mod for personal development with the minetest API. I want to make a simple block that automatically mines a set area. Here is some pseudo code:

Code: Select all

If minetest.register_abm = true
For loop < 100:
posArray = [posY = current.y - 1, posXP = current.x + 1, posXN = current.x - 1, posZP = current.z + 1, posZN = current.z - 1]
set  node(posArray) to node(default:air)
End For
End If
Does the air interfere with the gravity function or does it allow mine block to fall into the position below replaced by air and could someone give me an example of how I can run the loop within the minetest.register_abm function.

Please realize that I am only starting with minetest and so all help would be great. I haven't really used LUA for a lot at all. I have come from learning python, java and now C++ for desktop applications.

I am only experimenting at the moment as I need a project to keep me busy and this might be it but that depends on the support.

User avatar
Zeg9
Member
Posts: 608
Joined: Fri Sep 21, 2012 11:02
Location: France

by Zeg9 » Post

JWinch wrote:could someone give me an example of how I can run the loop within the minetest.register_abm function.

Code: Select all

minetest.register_abm({
    nodenames = {"yourmod:yournode"},
    interval=1.0, -- in seconds
    chance=1,
    action = function(pos, node, ...)
        for x=-1,1 do
        for y=-1,1 do
        for z=-1,1 do
            minetest.remove_node({x=pos.x+x, y=pos.y+y, z=pos.z+z})
        done
        done
        done
    end,
})
This one will remove a 3x3 area around "yourmod:yournode", every second, with a probability of 1/1.
Of course you have to register your node first.
Last edited by Zeg9 on Wed Jul 03, 2013 16:48, edited 1 time in total.
I made a few (a lot of?) mods for minetest: here is a list.
See also the MT-Faithful texture pack (work in progress).

User avatar
CODE_MACHINE
New member
Posts: 4
Joined: Sat Jun 29, 2013 10:21
Location: Derbyshire, England

by CODE_MACHINE » Post

Zeg9 wrote:
JWinch wrote:could someone give me an example of how I can run the loop within the minetest.register_abm function.

Code: Select all

minetest.register_abm({
    nodenames = {"yourmod:yournode"},
    interval=1.0, -- in seconds
    chance=1,
    action = function(pos, node, ...)
        for x=-1,1 do
        for y=-1,1 do
        for z=-1,1 do
            minetest.remove_node({x=pos.x+x, y=pos.y+y, z=pos.z+z})
        done
        done
        done
    end,
})
This one will remove a 3x3 area around "yourmod:yournode", every second, with a probability of 1/1.
Of course you have to register your node first.
Thanks a bunch! I see what you mean about the 3x3 area being removed. If I had done it my way it would have removed a + shape. So by adding the interval within the minetest.register_abm function it runs the function at the set number of seconds. I have declared my node and set gravity to on.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests