2020-08-04 19:50:13 +02:00
|
|
|
local S = minetest.get_translator("fake_fire")
|
2015-05-15 10:45:21 +02:00
|
|
|
|
2020-06-03 06:11:42 +02:00
|
|
|
local function fire_particles_on(pos) -- 3 layers of fire
|
|
|
|
local meta = minetest.get_meta(pos)
|
2020-08-04 19:50:13 +02:00
|
|
|
local id1 = minetest.add_particlespawner({ -- 1 layer big particles fire
|
2020-06-03 06:11:42 +02:00
|
|
|
amount = 9,
|
|
|
|
time = 0,
|
|
|
|
minpos = {x = pos.x - 0.2, y = pos.y - 0.4, z = pos.z - 0.2},
|
|
|
|
maxpos = {x = pos.x + 0.2, y = pos.y - 0.1, z = pos.z + 0.2},
|
|
|
|
minvel = {x= 0, y= 0, z= 0},
|
|
|
|
maxvel = {x= 0, y= 0.1, z= 0},
|
|
|
|
minacc = {x= 0, y= 0, z= 0},
|
|
|
|
maxacc = {x= 0, y= 0.7, z= 0},
|
|
|
|
minexptime = 0.5,
|
|
|
|
maxexptime = 0.7,
|
|
|
|
minsize = 2,
|
|
|
|
maxsize = 5,
|
|
|
|
collisiondetection = false,
|
|
|
|
vertical = true,
|
|
|
|
texture = "fake_fire_particle_anim_fire.png",
|
|
|
|
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 0.8,},
|
|
|
|
})
|
2020-08-04 19:50:13 +02:00
|
|
|
meta:set_int("layer_1", id1)
|
2020-06-03 06:11:42 +02:00
|
|
|
|
2020-08-04 19:50:13 +02:00
|
|
|
local id2 = minetest.add_particlespawner({ -- 2 layer smol particles fire
|
2020-06-03 06:11:42 +02:00
|
|
|
amount = 1,
|
|
|
|
time = 0,
|
|
|
|
minpos = {x = pos.x - 0.1, y = pos.y, z = pos.z - 0.1},
|
|
|
|
maxpos = {x = pos.x + 0.1, y = pos.y + 0.4, z = pos.z + 0.1},
|
|
|
|
minvel = {x= 0, y= 0, z= 0},
|
|
|
|
maxvel = {x= 0, y= 0.1, z= 0},
|
|
|
|
minacc = {x= 0, y= 0, z= 0},
|
|
|
|
maxacc = {x= 0, y= 1, z= 0},
|
|
|
|
minexptime = 0.4,
|
|
|
|
maxexptime = 0.6,
|
|
|
|
minsize = 0.5,
|
|
|
|
maxsize = 0.7,
|
|
|
|
collisiondetection = false,
|
|
|
|
vertical = true,
|
|
|
|
texture = "fake_fire_particle_anim_fire.png",
|
|
|
|
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 0.7,},
|
|
|
|
})
|
2020-08-04 19:50:13 +02:00
|
|
|
meta:set_int("layer_2", id2)
|
2020-06-03 06:11:42 +02:00
|
|
|
|
2020-08-04 19:50:13 +02:00
|
|
|
local id3 = minetest.add_particlespawner({ --3 layer smoke
|
2020-06-03 06:11:42 +02:00
|
|
|
amount = 1,
|
|
|
|
time = 0,
|
|
|
|
minpos = {x = pos.x - 0.1, y = pos.y - 0.2, z = pos.z - 0.1},
|
|
|
|
maxpos = {x = pos.x + 0.2, y = pos.y + 0.4, z = pos.z + 0.2},
|
|
|
|
minvel = {x= 0, y= 0, z= 0},
|
|
|
|
maxvel = {x= 0, y= 0.1, z= 0},
|
|
|
|
minacc = {x= 0, y= 0, z= 0},
|
|
|
|
maxacc = {x= 0, y= 1, z= 0},
|
|
|
|
minexptime = 0.6,
|
|
|
|
maxexptime = 0.8,
|
|
|
|
minsize = 2,
|
|
|
|
maxsize = 4,
|
|
|
|
collisiondetection = true,
|
|
|
|
vertical = true,
|
|
|
|
texture = "fake_fire_particle_anim_smoke.png",
|
|
|
|
animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length = 0.9,},
|
|
|
|
})
|
2020-08-04 19:50:13 +02:00
|
|
|
meta:set_int("layer_3", id3)
|
2020-06-03 06:11:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function fire_particles_off(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local id_1 = meta:get_int("layer_1");
|
|
|
|
local id_2 = meta:get_int("layer_2");
|
|
|
|
local id_3 = meta:get_int("layer_3");
|
|
|
|
minetest.delete_particlespawner(id_1)
|
|
|
|
minetest.delete_particlespawner(id_2)
|
|
|
|
minetest.delete_particlespawner(id_3)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function start_fire_effects(pos, node, clicker, chimney)
|
2015-05-03 13:03:14 +02:00
|
|
|
local this_spawner_meta = minetest.get_meta(pos)
|
|
|
|
local id = this_spawner_meta:get_int("smoky")
|
|
|
|
local s_handle = this_spawner_meta:get_int("sound")
|
|
|
|
local above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
|
|
|
|
|
|
|
|
if id ~= 0 then
|
|
|
|
if s_handle then
|
2016-12-15 23:24:11 +01:00
|
|
|
minetest.after(0, function(handle)
|
|
|
|
minetest.sound_stop(handle)
|
2015-05-03 13:03:14 +02:00
|
|
|
end, s_handle)
|
|
|
|
end
|
|
|
|
minetest.delete_particlespawner(id)
|
2018-06-11 20:06:37 +02:00
|
|
|
this_spawner_meta:set_int("smoky", 0)
|
|
|
|
this_spawner_meta:set_int("sound", 0)
|
2015-05-03 13:03:14 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if above == "air" and (not id or id == 0) then
|
|
|
|
id = minetest.add_particlespawner({
|
2015-05-23 15:14:47 +02:00
|
|
|
amount = 4, time = 0, collisiondetection = true,
|
2015-05-03 13:03:14 +02:00
|
|
|
minpos = {x=pos.x-0.25, y=pos.y+0.4, z=pos.z-0.25},
|
|
|
|
maxpos = {x=pos.x+0.25, y=pos.y+5, z=pos.z+0.25},
|
|
|
|
minvel = {x=-0.2, y=0.3, z=-0.2}, maxvel = {x=0.2, y=1, z=0.2},
|
|
|
|
minacc = {x=0,y=0,z=0}, maxacc = {x=0,y=0.5,z=0},
|
|
|
|
minexptime = 1, maxexptime = 3,
|
|
|
|
minsize = 4, maxsize = 8,
|
|
|
|
texture = "smoke_particle.png",
|
|
|
|
})
|
|
|
|
if chimney == 1 then
|
|
|
|
this_spawner_meta:set_int("smoky", id)
|
2018-06-11 20:06:37 +02:00
|
|
|
this_spawner_meta:set_int("sound", 0)
|
2015-05-03 13:03:14 +02:00
|
|
|
else
|
2016-12-15 23:24:11 +01:00
|
|
|
s_handle = minetest.sound_play("fire_small", {
|
|
|
|
pos = pos,
|
|
|
|
max_hear_distance = 5,
|
|
|
|
loop = true
|
|
|
|
})
|
2020-06-03 06:11:42 +02:00
|
|
|
fire_particles_on(pos)
|
2016-12-15 23:24:11 +01:00
|
|
|
this_spawner_meta:set_int("sound", s_handle)
|
2015-05-03 13:03:14 +02:00
|
|
|
end
|
2016-12-15 23:24:11 +01:00
|
|
|
end
|
2015-05-03 13:03:14 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function stop_smoke(pos)
|
|
|
|
local this_spawner_meta = minetest.get_meta(pos)
|
|
|
|
local id = this_spawner_meta:get_int("smoky")
|
|
|
|
local s_handle = this_spawner_meta:get_int("sound")
|
|
|
|
|
|
|
|
if id ~= 0 then
|
|
|
|
minetest.delete_particlespawner(id)
|
|
|
|
end
|
|
|
|
|
|
|
|
if s_handle then
|
2016-12-15 23:24:11 +01:00
|
|
|
minetest.after(0, function(handle)
|
|
|
|
minetest.sound_stop(handle)
|
2015-05-03 13:03:14 +02:00
|
|
|
end, s_handle)
|
|
|
|
end
|
|
|
|
|
2018-06-11 20:06:37 +02:00
|
|
|
this_spawner_meta:set_int("smoky", 0)
|
|
|
|
this_spawner_meta:set_int("sound", 0)
|
2015-05-03 13:03:14 +02:00
|
|
|
end
|
|
|
|
|
2017-08-13 00:21:50 +02:00
|
|
|
minetest.register_node("fake_fire:ice_fire", {
|
|
|
|
inventory_image = "ice_fire_inv.png",
|
2017-08-20 17:52:45 +02:00
|
|
|
description = S("Ice fire"),
|
2017-08-13 00:21:50 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2022-05-03 21:21:14 +02:00
|
|
|
groups = {dig_immediate=3, not_in_creative_inventory=1, dig_generic=3},
|
2017-08-13 00:21:50 +02:00
|
|
|
sunlight_propagates = true,
|
|
|
|
buildable_to = true,
|
|
|
|
walkable = false,
|
|
|
|
light_source = 14,
|
|
|
|
waving = 1,
|
|
|
|
tiles = {
|
|
|
|
{name="ice_fire_animated.png", animation={type="vertical_frames",
|
|
|
|
aspect_w=16, aspect_h=16, length=1.5}},
|
|
|
|
},
|
|
|
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
2020-06-03 06:11:42 +02:00
|
|
|
start_fire_effects(pos, node, clicker)
|
2017-08-13 00:21:50 +02:00
|
|
|
return itemstack
|
|
|
|
end,
|
|
|
|
on_destruct = function (pos)
|
|
|
|
stop_smoke(pos)
|
|
|
|
minetest.sound_play("fire_extinguish", {
|
|
|
|
pos = pos, max_hear_distance = 5
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
drop = ""
|
|
|
|
})
|
2015-05-03 13:03:14 +02:00
|
|
|
|
2017-08-13 00:21:50 +02:00
|
|
|
minetest.register_alias("fake_fire:fake_fire", "fire:permanent_flame")
|
2015-05-03 13:03:14 +02:00
|
|
|
|
2020-06-03 06:11:42 +02:00
|
|
|
local sbox = {
|
|
|
|
type = 'fixed',
|
|
|
|
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16},
|
|
|
|
}
|
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
local wtex = homedecor.textures.default_junglewood
|
|
|
|
|
2015-05-03 13:03:14 +02:00
|
|
|
minetest.register_node("fake_fire:fancy_fire", {
|
2020-06-03 06:11:42 +02:00
|
|
|
inventory_image = "fancy_fire_inv.png",
|
|
|
|
description = S("Fancy Fire"),
|
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "fancy_fire.obj",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2022-02-07 14:18:17 +01:00
|
|
|
use_texture_alpha = "clip",
|
2020-06-03 06:11:42 +02:00
|
|
|
groups = {oddly_breakable_by_hand=3, flammable=0},
|
|
|
|
sunlight_propagates = true,
|
|
|
|
light_source = 13,
|
|
|
|
walkable = false,
|
|
|
|
buildable_to = false,
|
|
|
|
damage_per_second = 3,
|
|
|
|
selection_box = sbox,
|
|
|
|
tiles = {
|
|
|
|
"basic_materials_concrete_block.png",
|
2022-05-03 21:21:14 +02:00
|
|
|
wtex,
|
2020-06-03 06:11:42 +02:00
|
|
|
"fake_fire_empty_tile.png"
|
|
|
|
},
|
|
|
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|
|
|
fire_particles_on(pos)
|
|
|
|
return itemstack
|
|
|
|
end,
|
|
|
|
on_construct = function(pos)
|
|
|
|
fire_particles_on(pos)
|
|
|
|
end,
|
|
|
|
on_destruct = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
fire_particles_off(pos)
|
|
|
|
minetest.sound_play("fire_extinguish", {
|
|
|
|
pos = pos, max_hear_distance = 5
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
drop = {
|
|
|
|
max_items = 3,
|
|
|
|
items = {
|
|
|
|
{
|
|
|
|
items = { "default:torch", "default:torch", "building_blocks:sticks" },
|
|
|
|
rarity = 1,
|
2015-05-03 18:39:58 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-03 06:11:42 +02:00
|
|
|
}
|
|
|
|
})
|
2015-05-03 13:03:14 +02:00
|
|
|
|
|
|
|
-- EMBERS
|
|
|
|
minetest.register_node("fake_fire:embers", {
|
2017-01-29 22:41:03 +01:00
|
|
|
description = S("Glowing Embers"),
|
2015-05-03 13:03:14 +02:00
|
|
|
tiles = {
|
|
|
|
{name="embers_animated.png", animation={type="vertical_frames",
|
|
|
|
aspect_w=16, aspect_h=16, length=2}},
|
|
|
|
},
|
|
|
|
light_source = 9,
|
2022-05-03 21:21:14 +02:00
|
|
|
groups = {crumbly=3, dig_stone=2},
|
2015-05-03 13:03:14 +02:00
|
|
|
paramtype = "light",
|
2022-05-03 21:21:14 +02:00
|
|
|
_sound_def = {
|
|
|
|
key = "node_sound_dirt_defaults",
|
|
|
|
},
|
2015-05-03 13:03:14 +02:00
|
|
|
})
|
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
local sandstone_tex = "default_sandstone.png"
|
|
|
|
if not minetest.get_modpath("default") then
|
|
|
|
local sname = minetest.registered_nodes["mapgen_stone"].name
|
|
|
|
local names = sname:split(":")
|
|
|
|
local nitem = names[2] and string.gsub(names[2], "stone", "sandstone") or nil
|
|
|
|
if nitem and minetest.registered_nodes[names[1]..":"..nitem] then
|
|
|
|
sandstone_tex = minetest.registered_nodes[names[1]..":"..nitem].tiles[1]
|
|
|
|
else
|
|
|
|
sandstone_tex = "[combine:16x16^[noalpha^[colorize:#fefebe"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-03 13:03:14 +02:00
|
|
|
-- CHIMNEYS
|
2017-01-31 06:34:41 +01:00
|
|
|
local materials = {
|
2022-05-03 21:21:14 +02:00
|
|
|
{ "stone", S("Stone chimney top"), minetest.registered_nodes["mapgen_stone"].tiles[1] },
|
|
|
|
{ "sandstone", S("Sandstone chimney top"), sandstone_tex },
|
2017-01-31 06:34:41 +01:00
|
|
|
}
|
2015-05-03 13:03:14 +02:00
|
|
|
|
2017-01-31 06:34:41 +01:00
|
|
|
for _, mat in ipairs(materials) do
|
2022-05-03 21:21:14 +02:00
|
|
|
local name, desc, tex = unpack(mat)
|
2017-01-31 06:34:41 +01:00
|
|
|
minetest.register_node("fake_fire:chimney_top_"..name, {
|
|
|
|
description = desc,
|
2022-05-03 21:21:14 +02:00
|
|
|
tiles = {tex.."^chimney_top.png", tex},
|
|
|
|
groups = {snappy=3, dig_stone=2},
|
2015-05-03 13:03:14 +02:00
|
|
|
paramtype = "light",
|
2022-05-03 21:21:14 +02:00
|
|
|
_sound_def = {
|
|
|
|
key = "node_sound_stone_defaults",
|
|
|
|
},
|
2015-05-03 13:03:14 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
|
|
|
},
|
2016-07-31 01:17:23 +02:00
|
|
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
2015-05-03 13:03:14 +02:00
|
|
|
local chimney = 1
|
2020-06-03 06:11:42 +02:00
|
|
|
start_fire_effects(pos, node, clicker, chimney)
|
2016-07-31 01:17:23 +02:00
|
|
|
return itemstack
|
2015-05-03 13:03:14 +02:00
|
|
|
end,
|
|
|
|
on_destruct = function (pos)
|
|
|
|
stop_smoke(pos)
|
|
|
|
end
|
|
|
|
})
|
2016-12-15 22:23:31 +01:00
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
if minetest.get_modpath("default") then
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = 'fake_fire:chimney_top_'..name,
|
|
|
|
recipe = {"default:torch", "stairs:slab_"..name}
|
|
|
|
})
|
|
|
|
end
|
2015-05-03 13:03:14 +02:00
|
|
|
end
|
|
|
|
|
2017-08-13 00:21:50 +02:00
|
|
|
minetest.register_alias("fake_fire:flint_and_steel", "fire:flint_and_steel")
|
2015-05-03 13:03:14 +02:00
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
if minetest.get_modpath("default") then
|
|
|
|
minetest.override_item("default:ice", {
|
|
|
|
on_ignite = function(pos, igniter)
|
|
|
|
local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z}
|
|
|
|
if minetest.get_node(flame_pos).name == "air" then
|
|
|
|
minetest.set_node(flame_pos, {name = "fake_fire:ice_fire"})
|
|
|
|
end
|
2017-08-13 00:21:50 +02:00
|
|
|
end
|
2022-05-03 21:21:14 +02:00
|
|
|
})
|
|
|
|
end
|
2015-05-03 13:03:14 +02:00
|
|
|
|
|
|
|
-- CRAFTS
|
2022-05-03 21:21:14 +02:00
|
|
|
if minetest.get_modpath("default") then
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = 'fake_fire:embers',
|
|
|
|
recipe = {"default:torch", "group:wood", "default:torch"}
|
|
|
|
})
|
2015-05-03 13:03:14 +02:00
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = 'fake_fire:fancy_fire',
|
|
|
|
recipe = {"default:torch", "building_blocks:sticks", "default:torch" }
|
|
|
|
})
|
|
|
|
end
|
2015-05-03 13:03:14 +02:00
|
|
|
|
|
|
|
-- ALIASES
|
2020-06-03 06:20:03 +02:00
|
|
|
|
2015-05-03 13:03:14 +02:00
|
|
|
minetest.register_alias("fake_fire:smokeless_fire", "fake_fire:fake_fire")
|
|
|
|
minetest.register_alias("fake_fire:smokeless_ice_fire", "fake_fire:ice_fire")
|
|
|
|
minetest.register_alias("fake_fire:smokeless_chimney_top_stone", "fake_fire:chimney_top_stone")
|
|
|
|
minetest.register_alias("fake_fire:smokeless_chimney_top_sandstone", "fake_fire:chimney_top_sandstone")
|
|
|
|
minetest.register_alias("fake_fire:flint", "fake_fire:flint_and_steel")
|
2020-06-03 06:20:03 +02:00
|
|
|
|
|
|
|
-- OTHER
|
|
|
|
|
|
|
|
minetest.register_lbm({
|
|
|
|
name = "fake_fire:reload_particles",
|
|
|
|
label = "restart fire particles on reload",
|
|
|
|
nodenames = {"fake_fire:fancy_fire"},
|
|
|
|
run_at_every_load = true,
|
|
|
|
action = function(pos, node)
|
|
|
|
fire_particles_off(pos)
|
|
|
|
fire_particles_on(pos)
|
|
|
|
end
|
|
|
|
})
|