Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Commit

Permalink
Dead fires can be relit by neighbors, with new inferno.ignite() function
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyshannon committed May 18, 2022
1 parent 76881da commit 2ec9dbb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
25 changes: 17 additions & 8 deletions mods/inferno/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end

-- Flame nodes

flame_def = {
local flame_def = {
drawtype = "firelike",
tiles = {
{
Expand Down Expand Up @@ -251,7 +251,7 @@ minetest.register_abm({
label = "Remove flammable nodes",
nodenames = {"group:flammable"},
neighbors = {"group:flames", "group:igniter"},
interval = 26,
interval = 6,
chance = 8,
catch_up = false,
action = function(pos)
Expand Down Expand Up @@ -303,6 +303,19 @@ local lit = {
["tech:large_charcoal_fire_ext"] = "tech:large_charcoal_fire",
}

function inferno.ignite(pos, nodename)
if nodename == nil or nodename == "" then
nodename = minetest.get_node(pos).name
end
for unl, l in pairs(lit) do
if nodename == unl then
minimal.switch_node(pos, {name = l})
return true
end
end
return false
end

-- Fire Sticks
minetest.register_tool("inferno:fire_sticks", {
description = S("Fire Sticks"),
Expand All @@ -319,12 +332,8 @@ minetest.register_tool("inferno:fire_sticks", {
if pointed_thing.type == "node" then
local node_under = minetest.get_node(pointed_thing.under).name
local pos_under = pointed_thing.under

for unl, l in pairs(lit) do
if node_under == unl then
minimal.switch_node(pointed_thing.under, {name = l})
return add_wear(player_name, itemstack, sound_pos)
end
if inferno.ignite(pos_under, node_under) then
return add_wear(player_name, itemstack, sound_pos)
end

local nodedef = minetest.registered_nodes[node_under]
Expand Down
15 changes: 14 additions & 1 deletion mods/tech/fires.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ local char_temp_effect = wood_temp_effect * 2
local char_temp_max = wood_temp_max * 2
local char_air_c = 0.45

inferno = inferno

-------------------------------
--Functions

Expand Down Expand Up @@ -735,7 +737,9 @@ minetest.register_node('tech:small_wood_fire_ext', {

on_dig = on_dig_fire,
after_place_node = after_place_fire,

on_burn = function(pos)
inferno.ignite(pos)
end,
})


Expand All @@ -747,6 +751,9 @@ minetest.register_node('tech:large_wood_fire_ext', {

on_dig = on_dig_fire,
after_place_node = after_place_fire,
on_burn = function(pos)
inferno.ignite(pos)
end,

})

Expand All @@ -767,6 +774,9 @@ minetest.register_node('tech:small_charcoal_fire_ext', {

on_dig = on_dig_fire,
after_place_node = after_place_fire,
on_burn = function(pos)
inferno.ignite(pos)
end,

})

Expand All @@ -779,6 +789,9 @@ minetest.register_node('tech:large_charcoal_fire_ext', {

on_dig = on_dig_fire,
after_place_node = after_place_fire,
on_burn = function(pos)
inferno.ignite(pos)
end,

})

Expand Down

0 comments on commit 2ec9dbb

Please sign in to comment.