~fgaz/minetest-falling_nodes

51a13e61de2048e79fca20a48d74ea3f427c5097 — Francesco Gazzetta 4 months ago 18bdbb1
Add spark tool
3 files changed, 13 insertions(+), 2 deletions(-)

M mods/falling_nodes/init.lua
M mods/falling_nodes/materials.lua
A mods/falling_nodes/tools.lua
M mods/falling_nodes/init.lua => mods/falling_nodes/init.lua +1 -0
@@ 16,3 16,4 @@ dofile(minetest.get_modpath(modname) .. "/states_of_matter.lua")
dofile(minetest.get_modpath(modname) .. "/explosions.lua")
dofile(minetest.get_modpath(modname) .. "/materials.lua")
dofile(minetest.get_modpath(modname) .. "/walls.lua")
dofile(minetest.get_modpath(modname) .. "/tools.lua")

M mods/falling_nodes/materials.lua => mods/falling_nodes/materials.lua +0 -2
@@ 256,5 256,3 @@ minetest.register_abm {
    minetest.get_node_timer(pos):start(METAL_POWERED_DECAY_TIME)
  end,
}

-- TODO add spark tool

A mods/falling_nodes/tools.lua => mods/falling_nodes/tools.lua +12 -0
@@ 0,0 1,12 @@
minetest.register_tool("falling_nodes:spark", {
  description = "Spark\nGenerates electricity on the clicked node",
  short_description = "Spark",
  inventory_image = "[fill:1x1:#FFFF80",
  on_place = function(itemstack, placer, pointed_thing)
    local pos = pointed_thing.under
    if minetest.get_node(pos).name == "falling_nodes:metal" then
      minetest.swap_node(pos, {name = "falling_nodes:metal_powered"})
      minetest.get_node_timer(pos):start(0)
    end
  end,
})