This commit is contained in:
jp 2015-03-05 23:10:27 +01:00
parent db703e555d
commit dca81b1648
8 changed files with 41 additions and 354 deletions

View File

@ -1,37 +1,3 @@
--[[
The 'Fake-Fire' mod was originally created by Semmett9.
URL to the 'Fake-Fire' thread on Minetest.net:
http://forum.minetest.net/viewtopic.php?id=6145
I've customized it a bit. Please see the changelog.txt file for more details.
~ LazyJ, 2014_03_15
--]]
dofile(minetest.get_modpath("fake_fire").."/modfiles/nodes.lua")
dofile(minetest.get_modpath("fake_fire").."/modfiles/crafts.lua")
dofile(minetest.get_modpath("fake_fire").."/modfiles/abms.lua")
--[[
The lines below, at the end, are from the original author, Semmett9.
Thanks for a nice mod, Semmett9. ;)
~ LazyJ, 2014_03_14
--]]
-- Thanks-
-- Many thanks for addi for his help in coding. --
-- Many thanks for the players on the King Arthur's land server for giving --
-- me support, ideas and allowing me to add the mod to the server itself. --

View File

@ -1,52 +1,3 @@
--[[
I commented out this part because:
1. water and lava buckets are disabled on some servers,
2. putting out fire with water and especially lava would only make
a big mess, and...
As for 'realism':
* C'mon... This is *fake* fire.
* Torches have long been impervious to water.
* Minetest creates surreal worlds so it's OK if some things aren't
perfectly realistic.
Besides, the fake-fire can be put out by punching it - simple and effective.
~ LazyJ, 2014_03_14
-- water and lava puts out fake fire --
minetest.register_abm({
nodenames = {"fake_fire:fake_fire"},
interval = 1,
chance = 1,
action = function(pos, node)
if minetest.env:find_node_near(pos, 1, {"default:water_source",
"default:water_flowing","default:lava_source",
"default:lava_flowing"}) then
minetest.sound_play("fire_extinguish",
{gain = 1.0, max_hear_distance = 20,})
node.name = "air"
minetest.env:set_node(pos, node)
end
end
})
-- ADVISING ABOUT SMOKE PARTICLES SETTINGS
-- For the best visual result...
-- If you increase the particles size,
-- you should decrease the particles amount and/or increase the smoke column lenght.
-- If you increase the particle time duration and/or particle course,
-- you should decrease the particles amount or increase the smoke column lenght.
-- Or conversely...
-- ~ JP
--]]
minetest.register_abm({
nodenames = {
"fake_fire:fake_fire",
@ -57,13 +8,11 @@ minetest.register_abm({
interval = 1,
chance = 2,
action = function(pos, node)
if
minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}).name == "air" and
minetest.get_node({x=pos.x, y=pos.y+2.0, z=pos.z}).name == "air"
then
if minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}).name == "air"
and minetest.get_node({x=pos.x, y=pos.y+2.0, z=pos.z}).name == "air" then
local image_number = math.random(4)
minetest.add_particlespawner({
amount = 8,
amount = 6,
time = 1,
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+8, z=pos.z+0.25},
@ -78,7 +27,6 @@ minetest.register_abm({
collisiondetection = false,
texture = "smoke_particle_"..image_number..".png",
})
end
end
end
})

View File

@ -1,32 +1,3 @@
--[[
NEVER-ENDING FLINT and STEEL
Uncraftable, at the moment, and I'm not sure yet how many wanna-be-firebug
griefers are going to litter with fake-fire. Why give them this if it only
makes the mess bigger? ~ LazyJ, 2014_03_13
May add a priv for this later so trusted players can use it.
~ LazyJ, 2014_06_19
minetest.register_craftitem("fake_fire:old_flint_and_steel", {
description = "Never ending flint and steel",
inventory_image = "flint_and_steel.png",
stack_max = 1,
liquids_pointable = false,
on_use = function(itemstack, user, pointed_thing)
n = minetest.env:get_node(pointed_thing)
if pointed_thing.type == "node" then
minetest.env:add_node(pointed_thing.above,
{name="fake_fire:fake_fire"})
minetest.sound_play("",
{gain = 1.0, max_hear_distance = 20,})
end
end
})
--]]
-- RECIPE ITEM - FLINT
minetest.register_craftitem("fake_fire:flint", {
description = "flint",
@ -35,8 +6,6 @@ minetest.register_craftitem("fake_fire:flint", {
liquids_pointable = false,
})
-- FLINT
minetest.register_craft({
type = "shapeless",
@ -47,8 +16,6 @@ minetest.register_craft({
}
})
-- FLINT & STEEL
minetest.register_craft({
type = "shapeless",
@ -59,8 +26,6 @@ minetest.register_craft({
}
})
-- EMBERS
minetest.register_craft({
type = "shapeless",
@ -71,14 +36,6 @@ minetest.register_craft({
}
})
-- CHIMNEY TOPS - SMOKELESS
-- Only the smokeless kind will be craftable and shown in the inventory.
-- The nodes are coded to switch to the smoking chimney tops when punched.
-- ~ LazyJ
-- STONE CHIMNEY TOP
minetest.register_craft({
type = "shapeless",
@ -89,8 +46,6 @@ minetest.register_craft({
}
})
-- SANDSTONE CHIMNEY TOP
minetest.register_craft({
type = "shapeless",
@ -101,35 +56,6 @@ minetest.register_craft({
}
})
-- Crafting Chain - Cobble-to-Gravel-to-Sand and Convert Sands
--[[
Craft one cobble into one gravel.
Craft one gravel into one sand.
Convert-craft sand to desert sand and vice-versa.
This was suggested by klappspaten and it makes sense in both its natural
progression and as a practical way for players to get some of the non-
renewable resources that they need.
Because the gravel-to-sand recipe (from one of our other custom mods)
conflicted with the Fake Fire mod's flint recipe, the Fake Fire mod's
recipe was changed to require 2 gravel.
I've added the cobble-gravel-sand and convert sands recipes as a bonus and
to make-up for the more expensive flint recipe. You can comment-out these
recipes because they aren't *required* by this fork of Fake Fire, but they
*are* handy recipes to have.
~ LazyJ
--]]
-- Cobble to Gravel
minetest.register_craft({
output = 'default:gravel',
@ -138,8 +64,6 @@ minetest.register_craft({
}
})
-- Gravel to Sand
minetest.register_craft({
output = 'default:sand',
@ -148,8 +72,6 @@ minetest.register_craft({
}
})
-- Desert Sand to Sand
minetest.register_craft({
output = 'default:sand',
@ -158,12 +80,10 @@ minetest.register_craft({
}
})
-- Sand to Desert Sand
minetest.register_craft({
output = 'default:desert_sand',
recipe = {
{'default:sand'},
}
})
})

View File

@ -4,54 +4,41 @@ local function register_fake_fire(name, def)
assert(name, "local registration called without name")
assert(def, "local registration called without node definition")
-- make sure shared definitions are set
def.is_ground_content = true
def.inventory_image = def.inventory_image or name.. ".png"
def.inventory_image = def.inventory_image or name..".png"
def.drawtype = "plantlike"
def.waving = 1 -- Waving wasn't an option when this mod was written. ~ LazyJ, 2014_03_13
def.waving = 1
def.light_source = def.lightsource or 14
-- Adding sunlight_propagtes and leaving comments as a future reference.
-- If true, sunlight will go infinitely through this (no shadow is cast).
-- Because fire produces light it should be "true" so fire *doesn't* have
-- a shadow.
def.sunlight_propagates = true
-- damage_per_second = 2*0.5, -- It's *fake* fire. PvP on our server has
-- been disabled for a reason. I don't want griefers lighting players on
-- fire or trapping them in blazes. ~ LazyJ, 2014_0_13
def.groups = def.groups or {
oddly_breakable_by_hand=3, dig_immediate=2,
attached_node=1, not_in_creative_inventory=1
}
def.paramtype = "light"
def.walkable = false
def.drop = "" -- So fire won't return to the inventory. ~ LazyJ
def.drop = ""
def.sounds = def.sounds or minetest.sound_play("fire_small", {pos=cp, loop=true})
def.buildable_to = true
local swap_on_punch = def.swap_on_punch
def.on_punch = def.on_punch or function (pos, node, puncher)
-- A max_hear_distance of 20 may freak some players out by the "hiss"
-- so I reduced it to 5.
minetest.sound_play("fire_extinguish", {pos = pos, gain = 1.0, max_hear_distance = 5,})
-- swap the node on_punch if def.swap_on_punch is set
if swap_on_punch then
minetest.set_node(pos, {name = swap_on_punch})
end
end
-- no need to add these to the global registration table
def.swap_on_punch = nil
def.smoking = nil
minetest.register_node("fake_fire:" .. name, def)
minetest.register_node("fake_fire:"..name, def)
end
-- FLAME TYPES
register_fake_fire("fake_fire", {
description = "Smokey, Fake Fire",
tiles = {
{name="fake_fire_animated.png", animation={type="vertical_frames",
aspect_w=16, aspect_h=16, length=1.5}},
{name="fake_fire_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1.5}},
},
swap_on_punch = "fake_fire:smokeless_fire",
})
@ -59,8 +46,7 @@ register_fake_fire("fake_fire", {
register_fake_fire("smokeless_fire", {
description = "Smokeless, Fake Fire",
tiles = {
{name="fake_fire_animated.png", animation={type="vertical_frames",
aspect_w=16, aspect_h=16, length=1.5}},
{name="fake_fire_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1.5}},
},
inventory_image = 'fake_fire.png',
swap_on_punch = "fake_fire:fake_fire",
@ -69,8 +55,7 @@ register_fake_fire("smokeless_fire", {
register_fake_fire("ice_fire", {
description = "Smoky, Fake, Ice Fire",
tiles = {
{name="ice_fire_animated.png", animation={type="vertical_frames",
aspect_w=16, aspect_h=16, length=1.5}},
{name="ice_fire_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1.5}},
},
swap_on_punch = "fake_fire:smokeless_ice_fire",
})
@ -78,13 +63,13 @@ register_fake_fire("ice_fire", {
register_fake_fire("smokeless_ice_fire", {
description = "Smokeless, Fake, Ice Fire",
tiles = {
{name="ice_fire_animated.png", animation={type="vertical_frames",
aspect_w=16, aspect_h=16, length=1.5}},
{name="ice_fire_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1.5}},
},
inventory_image = 'ice_fire.png',
swap_on_punch = "fake_fire:ice_fire",
})
-- FLINT and STEEL
minetest.register_tool("fake_fire:flint_and_steel", {
description = "Flint and steel",
@ -98,138 +83,40 @@ minetest.register_tool("fake_fire:flint_and_steel", {
}
},
on_use = function(itemstack, user, pointed_thing)
-- This next section took me a lot of keyboard bashing to figure out.
-- The lua documentation and examples for Minetest are terrible.
-- ~ LazyJ, 2014_06_23
local snow_ice_list = {"snow", "ice",}
for _, which_one_is_it in pairs(snow_ice_list) do
local snow_ice = which_one_is_it
if
-- A *node*, not a player or sprite. ~ LazyJ
pointed_thing.type == "node"
--[[
These next two "and nots" tell Minetest not to put the
red flame on snow and ice stuff. This "string" bit was
the workable solution that took many hours, over
several days, to finally come around to. It's a search
for any node name that contains whatever is between the
double-quotes, ie. "snow" or "ice". I had been trying
to identify the nodes by their group properties and I
couldn't figure out how to do it. The clue for the
"string"came from Blockmen's "Landscape" mod.
Another quirk is that the "string" doesn't work well
with variable lists (see "snow_ice_list") when using
"and not". Ice-fire would light on snow but when I
clicked on ice, the regular flame appeared. I couldn't
understand what was happening until I mentally changed
the wording "and not" to "is not" and spoke out-loud
each thing that line of code was to accomplish:
"Is not snow, then make fake-fire."
"Is not ice, then make fake-fire."
That's when I caught the problem.
Ice *is not* snow, so Minetest was correctly following
the instruction, "Is not snow, then make fake-fire."
and that is why fake-fire appeared instead of ice-fire
when I clicked on ice.
~ LazyJ
--]]
and not
string.find(minetest.get_node(pointed_thing.under).name, "snow")
and not
string.find(minetest.get_node(pointed_thing.under).name, "ice")
and
minetest.get_node(pointed_thing.above).name == "air"
if pointed_thing.type == "node"
and not string.find(minetest.get_node(pointed_thing.under).name, "snow")
and not string.find(minetest.get_node(pointed_thing.under).name, "ice")
and minetest.get_node(pointed_thing.above).name == "air"
then
if not minetest.is_protected(pointed_thing.above, user:get_player_name()) then
minetest.set_node(pointed_thing.above, {name="fake_fire:smokeless_fire"})
else
minetest.chat_send_player(user:get_player_name(), "You can't set a fire in someone else's area!")
end
elseif
pointed_thing.type == "node"
and
-- Split this "string" across several lines because I ran out
-- of room while trying to adhere to the 80-column wide rule
-- of coding style.
string.find(
minetest.get_node(pointed_thing.under).name,
snow_ice
)
and
minetest.get_node(pointed_thing.above).name == "air"
then
if not minetest.is_protected(pointed_thing.above, user:get_player_name()) then
minetest.set_node(pointed_thing.above, {name="fake_fire:smokeless_ice_fire"})
else
minetest.chat_send_player(user:get_player_name(), "You can't set a fire in someone else's area!")
end
end -- Line 210, if
end -- Line 207, for/do
elseif pointed_thing.type == "node"
and string.find(minetest.get_node(pointed_thing.under).name,snow_ice)
and minetest.get_node(pointed_thing.above).name == "air" then
if not minetest.is_protected(pointed_thing.above, user:get_player_name()) then
minetest.set_node(pointed_thing.above, {name="fake_fire:smokeless_ice_fire"})
else
minetest.chat_send_player(user:get_player_name(), "You can't set a fire in someone else's area!")
end
end
end
minetest.sound_play("",
{gain = 1.0, max_hear_distance = 2,})
minetest.sound_play("", {gain = 1.0, max_hear_distance = 2,})
itemstack:add_wear(65535/65)
return itemstack
end
}) -- Closes the flint and steel tool registration
--[[
SOME LESSONS LEARNED (and keeping this because I'll forget)
flint_and_steel is registered as a tool. Tools do not materialize something
like placing a block (on_construct) makes that block appear. Tools are
*used* so "on_use" works but not "on_construct".
on_rightclick is meant for the code of the thing being clicked on, not the
code of the thing doing the clicking.
~ LazyJ
--]]
-- ANIMATED, RISING, DISPAPPEARING SMOKE
--[[
These next two sections of code are a real bonus that I figured out how
to pull-off. ;)
The first section creates animated smoke. Trying to figure out how to make
the animation appear to go upward was a headache.
The second section places the animated smoke *only* above the fake-fire
*if* there is nothing but air straight above the fake-fire. I also made
the smoke skip a space so it looks more like puffs of smoke and made it
stretch high enough to be used in chimneys. For large builds, a second
fake-fire will have to be hidden close to the top of the chimney so the
smoke will be visible. The smoke also emmits a low-level light.
Yup, I'm proud of this little addition I've made to Semmett9's mod. :D
~ LazyJ, 2014_03_15
--]]
})
-- EMBERS
minetest.register_node("fake_fire:embers", {
description = "Glowing Embers",
tiles = {
@ -239,30 +126,15 @@ minetest.register_node("fake_fire:embers", {
inventory_image = minetest.inventorycube('fake_fire_embers.png'),
is_ground_content = true,
light_source = 9,
-- Adding sunlight_propagtes and leaving comments as a future reference.
-- If true, sunlight will go infinitely through this (no shadow is cast).
-- Because embers produce some light it should be somewhat "true" but this
-- is an area where Minetest lacks in subtlety so I'm opting for 100% that
-- embers *don't* have a shadow.
sunlight_propagates = true,
-- It's almost soft, brittle charcoal. ~ LazyJ
groups = {choppy=3, crumbly=3, oddly_breakable_by_hand=3},
paramtype = "light",
-- You never know when a creative builder may use the screwdriver or
-- position to create a subtle effect that makes their creation just
-- that little bit nicer looking. ~ Lazyj
paramtype2 = "facedir",
walkable = true,
sounds = minetest.sound_play("fire_small", {pos=cp, loop=true}),
})
-- CHIMNEY TOPS
-- Stone (cool tone) to go with cool colors.
-- Sandstone (warm tone) to go with warm colors.
-- CHIMNEY TOP - STONE
minetest.register_node("fake_fire:chimney_top_stone", {
description = "Chimney Top - Stone",
@ -278,14 +150,11 @@ minetest.register_node("fake_fire:chimney_top_stone", {
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_punch = function (pos,node,puncher)
-- This swaps the smokeless version with the smoky version when punched.
-- ~ LazyJ
minetest.set_node(pos, {name = "fake_fire:smokeless_chimney_top_stone"})
end
})
-- CHIMNEY TOP - SANDSTONE
minetest.register_node("fake_fire:chimney_top_sandstone", {
description = "Chimney Top - Sandstone",
@ -301,22 +170,11 @@ minetest.register_node("fake_fire:chimney_top_sandstone", {
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_punch = function (pos,node,puncher)
-- This swaps the smokeless version with the smoky version when punched.
-- ~ LazyJ
minetest.set_node(pos,
{name = "fake_fire:smokeless_chimney_top_sandstone"})
minetest.set_node(pos, {name = "fake_fire:smokeless_chimney_top_sandstone"})
end
})
-- SMOKELESS CHIMNEY TOPS
-- Some players may want a chimney top *without* smoke. This is the node
-- that will be craftable. To get the smoking variety, simply punch the
-- node. Same approach is used with the smoking and non-smoking flames.
-- ~ LazyJ
-- SMOKELESS CHIMNEY TOP - STONE
minetest.register_node("fake_fire:smokeless_chimney_top_stone", {
description = "Chimney Top - Stone",
@ -331,14 +189,11 @@ minetest.register_node("fake_fire:smokeless_chimney_top_stone", {
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_punch = function (pos,node,puncher)
-- This swaps the smokeless version with the smoky version when punched.
-- ~ LazyJ
minetest.set_node(pos, {name = "fake_fire:chimney_top_stone"})
end
})
-- SMOKELESS CHIMNEY TOP - SANDSTONE
minetest.register_node("fake_fire:smokeless_chimney_top_sandstone", {
description = "Chimney Top - Sandstone",
@ -353,8 +208,6 @@ minetest.register_node("fake_fire:smokeless_chimney_top_sandstone", {
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_punch = function (pos,node,puncher)
-- This swaps the smokeless version with the smoky version when punched.
-- ~ LazyJ
minetest.set_node(pos, {name = "fake_fire:chimney_top_sandstone"})
end
})

View File

@ -417,7 +417,7 @@ function homedecor.flip_door(pos, node, player, name, side, isClosed)
gain = 2,
})
-- XXX: does the top half have to remember open/closed too?
minetest.add_node({x=pos.x, y=pos.y+1, z=pos.z}, { name = "homedecor:door_"..name.."_top_"..rside, param2=nfdir})
minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, { name = "homedecor:door_"..name.."_top_"..rside, param2=nfdir})
addDoorNode(pos,{ name = "homedecor:door_"..name.."_bottom_"..rside, param2=nfdir },isClosed)
end

View File

@ -16,7 +16,7 @@ for i in ipairs(colors) do
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.add_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = 20})
minetest.set_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = 20})
end,
})
@ -25,7 +25,7 @@ for i in ipairs(colors) do
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.add_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = 20})
minetest.set_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = 20})
end,
})
@ -36,7 +36,7 @@ for i in ipairs(colors) do
action = function(pos, node, active_object_count, active_object_count_wider)
local fdir = node.param2 or 0
local nfdir = dirs2[fdir+1]
minetest.add_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = nfdir})
minetest.set_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = nfdir})
end,
})
@ -47,7 +47,7 @@ for i in ipairs(colors) do
action = function(pos, node, active_object_count, active_object_count_wider)
local fdir = node.param2 or 0
local nfdir = dirs2[fdir+1]
minetest.add_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = nfdir})
minetest.set_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = nfdir})
end,
})
@ -56,7 +56,7 @@ for i in ipairs(colors) do
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.add_node(pos, {name = "homedecor:glowlight_small_cube_"..color, param2 = 20})
minetest.set_node(pos, {name = "homedecor:glowlight_small_cube_"..color, param2 = 20})
end,
})

View File

@ -164,7 +164,7 @@ homedecor.register("fishtank", {
sounds = default.node_sound_glass_defaults(),
on_rightclick = function(pos, node, clicker)
fdir = minetest.get_node(pos).param2
minetest.add_node(pos, {name = "homedecor:fishtank_lighted", param2 = fdir})
minetest.set_node(pos, {name = "homedecor:fishtank_lighted", param2 = fdir})
end
})
@ -200,7 +200,7 @@ homedecor.register("fishtank_lighted", {
sounds = default.node_sound_glass_defaults(),
on_rightclick = function(pos, node, clicker)
fdir = minetest.get_node(pos).param2
minetest.add_node(pos, {name = "homedecor:fishtank", param2 = fdir})
minetest.set_node(pos, {name = "homedecor:fishtank", param2 = fdir})
end
})

View File

@ -110,7 +110,7 @@ minetest.register_abm({
action = function(pos, node, active_object_count, active_object_count_wider)
local newnode = string.sub(node.name, 1, -3) -- strip the "_s" from the name
local fdir = node.param2 or 0
minetest.add_node(pos, {name = newnode, param2 = dirs2[fdir+1]})
minetest.set_node(pos, {name = newnode, param2 = dirs2[fdir+1]})
end
})