~fgaz/minetest-falling_nodes

1266715c1ebcb2d661e503b224bdac8dc5f239a2 — Francesco Gazzetta 3 months ago e127f6d
Use register_material() to register materials
1 files changed, 15 insertions(+), 46 deletions(-)

M mods/falling_nodes/materials.lua
M mods/falling_nodes/materials.lua => mods/falling_nodes/materials.lua +15 -46
@@ 19,48 19,40 @@ function falling_nodes.register_material(name, original_def)
  minetest.register_node(name, def)
end

minetest.register_node("falling_nodes:sand", {
falling_nodes.register_material("falling_nodes:sand", {
  description = "Sand",
  tiles = {"falling_nodes_sand.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:powder"] = 1,
    dig_immediate = 3,
  },
})

minetest.register_node("falling_nodes:dust", {
falling_nodes.register_material("falling_nodes:dust", {
  description = "Dust",
  tiles = {"falling_nodes_dust.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:powder"] = 1,
    ["falling_nodes:flammable"] = 1,
    dig_immediate = 3,
  },
})

minetest.register_node("falling_nodes:gas", {
falling_nodes.register_material("falling_nodes:gas", {
  description = "Gas",
  tiles = {"falling_nodes_gas.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:gas"] = 1,
    ["falling_nodes:flammable"] = 1,
    dig_immediate = 3,
  },
  sunlight_propagates = true,
  drawtype = "glasslike_framed_optional",
  walkable = false,
})

minetest.register_node("falling_nodes:fire", {
falling_nodes.register_material("falling_nodes:fire", {
  description = "Fire",
  tiles = {"falling_nodes_fire.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:gas"] = 1,
    dig_immediate = 3,
  },
  sunlight_propagates = true,
  drawtype = "firelike",


@@ 78,36 70,29 @@ minetest.register_abm {
  action = function(pos) minetest.remove_node(pos) end,
}

minetest.register_node("falling_nodes:gunpowder", {
falling_nodes.register_material("falling_nodes:gunpowder", {
  description = "Gunpowder",
  tiles = {"falling_nodes_gunpowder.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:powder"] = 1,
    ["falling_nodes:deflagrating"] = 1,
    dig_immediate = 3,
  },
})

minetest.register_node("falling_nodes:tnt", {
falling_nodes.register_material("falling_nodes:tnt", {
  description = "TNT",
  tiles = {"falling_nodes_tnt.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:solid"] = 1,
    ["falling_nodes:detonating"] = 1,
    dig_immediate = 3,
  },
})

minetest.register_node("falling_nodes:clone", {
falling_nodes.register_material("falling_nodes:clone", {
  description = "Clone\nRight click to set cloned node",
  short_description = "Clone",
  tiles = {"falling_nodes_clone.png"},
  groups = {
    ["falling_nodes:material"] = 1, -- MAYBE remove, or better add group "indestructible"
    dig_immediate = 3,
  },
  -- MAYBE add group "indestructible"
  on_rightclick = function(pos, _node, _clicker, itemstack)
    if not itemstack or itemstack:is_empty() then return end
    local itemname = itemstack:get_name()


@@ 138,13 123,9 @@ minetest.register_abm {
  action = action_clone,
}

minetest.register_node("falling_nodes:void", {
falling_nodes.register_material("falling_nodes:void", {
  description = "Void",
  tiles = {"falling_nodes_void.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    dig_immediate = 3,
  },
})

local function action_void(pos)


@@ 167,25 148,21 @@ minetest.register_abm {
  action = action_void,
}

minetest.register_node("falling_nodes:oil", {
falling_nodes.register_material("falling_nodes:oil", {
  description = "Oil",
  tiles = {"falling_nodes_oil.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:liquid"] = 1,
    ["falling_nodes:flammable"] = 1,
    dig_immediate = 3,
  },
})

minetest.register_node("falling_nodes:wood", {
falling_nodes.register_material("falling_nodes:wood", {
  description = "Wood",
  tiles = {"falling_nodes_wood.png"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:solid"] = 1,
    ["falling_nodes:flammable"] = 1,
    dig_immediate = 3,
  },
})



@@ 199,23 176,19 @@ local METAL_POWERED_DECAY_TIME = minetest.settings:get("abm_interval") * 2
-- producing electricity loops (semi_powered metal is not conductive).
local METAL_SEMI_POWERED_DECAY_TIME = METAL_POWERED_DECAY_TIME * 3

minetest.register_node("falling_nodes:metal", {
falling_nodes.register_material("falling_nodes:metal", {
  description = "Metal",
  tiles = {"[fill:1x1:#404060"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:solid"] = 1,
    dig_immediate = 3,
  },
})

minetest.register_node("falling_nodes:metal_powered", {
falling_nodes.register_material("falling_nodes:metal_powered", {
  description = "Metal (powered)",
  tiles = {"[fill:1x1:#FFFF80"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:solid"] = 1,
    dig_immediate = 3,
    not_in_creative_inventory = 1,
  },
  on_construct = function(pos)


@@ 233,13 206,11 @@ minetest.register_node("falling_nodes:metal_powered", {
  end,
})

minetest.register_node("falling_nodes:metal_semi_powered", {
falling_nodes.register_material("falling_nodes:metal_semi_powered", {
  description = "Metal (unpowering)",
  tiles = {"[fill:1x1:#9F9F70"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:solid"] = 1,
    dig_immediate = 3,
    not_in_creative_inventory = 1,
  },
  on_construct = function(pos)


@@ 250,14 221,12 @@ minetest.register_node("falling_nodes:metal_semi_powered", {
  end,
})

minetest.register_node("falling_nodes:battery", {
falling_nodes.register_material("falling_nodes:battery", {
  description = "Battery\nGenerates electricity",
  short_description = "Battery",
  tiles = {"[fill:1x1:#858505"},
  groups = {
    ["falling_nodes:material"] = 1,
    ["falling_nodes:solid"] = 1,
    dig_immediate = 3,
  },
})