Page 1 of 1

[WIP] Virus mod

PostPosted: Mon Feb 03, 2014 03:02
by yaman
I am creating a mod where you can craft a block that takes over your world, I need some textures, the link to the texture requests is here. I will try to upload screenshots as soon as I have something worth showing.

Questions:
1. How to register a node that is unbreakable?
2. for this code, how to make it so that neigbors are all blocks? Do I just delete that line or do I put something there?
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_abm({
    nodenames = {"virus:corrupted_block"},
    neighbors = {"default:dirt"},
    interval = 5,
    chance = 1,
    action = function(pos, node, active_object_count, active_object_count_wider)
        minetest.set_node(pos, {name = "virus:corrupted_block"})
    end,
})

3. How do I make a schematic (see instabuild or something) ? I need this because the only purified block is going to be inside, and i need this building to spawn somewhere random in the currupted region



Corrupted Block for now: (NOT PERMANENT!!!)
Image

PostPosted: Mon Feb 03, 2014 10:57
by Dopium
1) The lua_api found in minetest/docs explains how to make nodes unbreakable.

2) You may want to look into how dirt with grass works.

PostPosted: Mon Feb 03, 2014 21:58
by yaman
Ok another question, Is there a group that is all nodes, like opposite of nil?

PostPosted: Tue Feb 04, 2014 11:24
by Krock
yaman wrote:Ok another question, Is there a group that is all nodes, like opposite of nil?

sure, like

node ~= nil

done

PostPosted: Tue Feb 04, 2014 16:35
by Grissess
yaman wrote:Ok another question, Is there a group that is all nodes, like opposite of nil?


From https://github.com/celeron55/minetest/blob/master/doc/lua_api.txt :

neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
^ If left out or empty, any neighbor will do


If you want to be sure that a node is actually a node (and not nothing), you might use node=minetest.get_node(pos), and then compare node.name to "air" (nothing) or "ignore" (not generated) :P

PostPosted: Tue Feb 04, 2014 18:09
by PilzAdam

PostPosted: Tue Feb 04, 2014 21:00
by yaman
I am sorry, I wrote my question wrong, what I meant to say is for registering abms, could the nodenames part select everything because
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
    nodenames = node ~= nil,
does not seem to work. Also for future developing, I am thinking of tree corrupted blocks, and cactus corrupted block so could I put something like
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
nodenames = if nodename = default.tree...
else...