Compare commits
3 Commits
master
...
campfire_s
Author | SHA1 | Date |
---|---|---|
TheRandomLegoBrick | d4bfd1fc3c | |
TheRandomLegoBrick | d366608c28 | |
TheRandomLegoBrick | 5beb878ec6 |
|
@ -3,13 +3,84 @@
|
||||||
-- ||||||||||||||||||||||||||||||||
|
-- ||||||||||||||||||||||||||||||||
|
||||||
|
|
||||||
-- TO-DO:
|
-- TO-DO:
|
||||||
-- * Add Smoke Particles
|
|
||||||
-- * Add Spark Particles
|
-- * Add Spark Particles
|
||||||
-- * Add Cooking Meat
|
-- * Add Cooking Meat
|
||||||
-- * Add Working Sounds
|
-- * Add Working Sounds
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
|
||||||
|
|
||||||
|
mcl_campfires = {}
|
||||||
|
|
||||||
|
function mcl_campfires.register_smoke(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
-- delete existing spawner
|
||||||
|
local existing_spawner = meta:get_int("smoke_particlespawner")
|
||||||
|
if existing_spawner ~= 0 then
|
||||||
|
minetest.delete_particlespawner(existing_spawner)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- velocity: 0.5
|
||||||
|
-- acceleration: 0.1
|
||||||
|
------------------------
|
||||||
|
-- 7 seconds ~= 10 nodes
|
||||||
|
-- 12 seconds ~= 20 nodes
|
||||||
|
|
||||||
|
local time = 7
|
||||||
|
if minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "mcl_farming:hay_block" then
|
||||||
|
time = 12
|
||||||
|
end
|
||||||
|
|
||||||
|
-- create new spawner
|
||||||
|
local smokeID = minetest.add_particlespawner({
|
||||||
|
time = 0,
|
||||||
|
ammount = 0.2,
|
||||||
|
collisiondetection = true,
|
||||||
|
texture = "mcl_campfires_smoke_4.png",
|
||||||
|
texpool = {
|
||||||
|
{ name = "mcl_campfires_smoke_0.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_2.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_3.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_4.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_5.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_7.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_8.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_9.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_1.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_10.png", alpha_tween = {1, 0}},
|
||||||
|
{ name = "mcl_campfires_smoke_11.png", alpha_tween = {1, 0}},
|
||||||
|
},
|
||||||
|
|
||||||
|
minpos = {x=pos.x - 0.25, y=pos.y + 0.25, z=pos.z - 0.25},
|
||||||
|
maxpos = {x=pos.x + 0.25, y=pos.y + 0.25, z=pos.z + 0.25},
|
||||||
|
minvel = {x=0, y=1, z=0},
|
||||||
|
maxvel = {x=0, y=1, z=0},
|
||||||
|
minacc = {x=0, y=0.1, z=0},
|
||||||
|
maxacc = {x=0, y=0.1, z=0},
|
||||||
|
minexptime = time,
|
||||||
|
maxexptime = time,
|
||||||
|
minsize = 12,
|
||||||
|
maxsize = 12,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- save the id in meta
|
||||||
|
meta:set_int("smoke_particlespawner", smokeID)
|
||||||
|
|
||||||
|
return smokeID
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_campfires.remove_smoke(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local smokeID = meta:get_int("smoke_particlespawner")
|
||||||
|
|
||||||
|
-- end function if smoke doesnt exist
|
||||||
|
if not smokeID then return 0 end
|
||||||
|
|
||||||
|
return minetest.delete_particlespawner(smokeID)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local campfires = {
|
local campfires = {
|
||||||
{ name = "Campfire", lightlevel = 14, techname = "campfire", damage = 1, drops = "mcl_core:charcoal_lump 2" },
|
{ name = "Campfire", lightlevel = 14, techname = "campfire", damage = 1, drops = "mcl_core:charcoal_lump 2" },
|
||||||
{ name = "Soul Campfire", lightlevel = 10, techname = "soul_campfire", damage = 2, drops = "mcl_blackstone:soul_soil" },
|
{ name = "Soul Campfire", lightlevel = 10, techname = "soul_campfire", damage = 2, drops = "mcl_blackstone:soul_soil" },
|
||||||
|
@ -78,11 +149,14 @@ for _, campfire in pairs(campfires) do
|
||||||
groups = { handy=1, axey=1, material_wood=1, campfire=1, lit_campfire=1 },
|
groups = { handy=1, axey=1, material_wood=1, campfire=1, lit_campfire=1 },
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
on_construct = mcl_campfires.register_smoke,
|
||||||
|
on_destruct = mcl_campfires.remove_smoke,
|
||||||
on_rightclick = function (pos, node, player, itemstack, pointed_thing)
|
on_rightclick = function (pos, node, player, itemstack, pointed_thing)
|
||||||
if player:get_wielded_item():get_name():find("shovel") then
|
if player:get_wielded_item():get_name():find("shovel") then
|
||||||
node.name = "mcl_campfires:" .. campfire.techname
|
node.name = "mcl_campfires:" .. campfire.techname
|
||||||
minetest.set_node(pos, node)
|
minetest.set_node(pos, node)
|
||||||
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
|
minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true)
|
||||||
|
mcl_campfires.remove_smoke(pos)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
drop = campfire.drops,
|
drop = campfire.drops,
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[LocalizedFileNames]
|
||||||
|
big_smoke_4.png=@big_smoke_4.png,0
|
After Width: | Height: | Size: 235 B |
After Width: | Height: | Size: 266 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 303 B |
After Width: | Height: | Size: 294 B |
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 298 B |
After Width: | Height: | Size: 298 B |
After Width: | Height: | Size: 256 B |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 240 B |
|
@ -148,6 +148,15 @@ if mod_screwdriver then
|
||||||
on_rotate = screwdriver.rotate_3way
|
on_rotate = screwdriver.rotate_3way
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function update_campfires(pos)
|
||||||
|
local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
|
local node_above = minetest.get_node(pos_above)
|
||||||
|
|
||||||
|
if node_above.name == "mcl_campfires:campfire_lit" or node_above.name == "mcl_campfires:soul_campfire_lit" then
|
||||||
|
mcl_campfires.register_smoke(pos_above)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_farming:hay_block", {
|
minetest.register_node("mcl_farming:hay_block", {
|
||||||
description = S("Hay Bale"),
|
description = S("Hay Bale"),
|
||||||
_doc_items_longdesc = S("Hay bales are decorative blocks made from wheat."),
|
_doc_items_longdesc = S("Hay bales are decorative blocks made from wheat."),
|
||||||
|
@ -156,6 +165,8 @@ minetest.register_node("mcl_farming:hay_block", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_place = mcl_util.rotate_axis,
|
on_place = mcl_util.rotate_axis,
|
||||||
|
on_construct = update_campfires,
|
||||||
|
after_destruct = update_campfires,
|
||||||
groups = {
|
groups = {
|
||||||
handy = 1, hoey = 1, building_block = 1, fall_damage_add_percent = -80,
|
handy = 1, hoey = 1, building_block = 1, fall_damage_add_percent = -80,
|
||||||
flammable = 2, fire_encouragement = 60, fire_flammability = 20,
|
flammable = 2, fire_encouragement = 60, fire_flammability = 20,
|
||||||
|
|