Large Update for 0.4.15

Large Rewrite to the mod so its uses the new things in the new minetest API
Added new sounds
Added new draw type
Fixed Old Bugs
master
Infinatum 2017-01-17 22:07:06 -01:00
parent f0d191b6a3
commit 1578f701cf
8 changed files with 101 additions and 89 deletions

View File

@ -1,2 +1,2 @@
default
fire?

188
init.lua
View File

@ -1,58 +1,81 @@
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --
-- FAKE FIRE MOD - Version 1.0 --
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ --
fake_fire_water = true;
-- function for fire --
local function set_fake_fire(pointed_thing, itemstack, wear)
local n = minetest.env:get_node(pointed_thing.above)
-- if the node is air then --
if n.name ~= "" and n.name == "air" then
-- create fire above that node --
minetest.env:set_node(pointed_thing.above, {name="fake_fire:fake_fire"})
-- then play the sound --
minetest.sound_play("fake_fire_light", {
pos = pointed_thing.above,
max_hear_distance = 10,
gain = 10.0,
})
-- degrade the item --
itemstack:add_wear(wear)
end
end
if fake_fire_water == true then
minetest.register_abm({
nodenames = {"fake_fire:fake_fire"},
neighbors = {"group:puts_out_fire"},
interval = 3,
chance = 1,
catch_up = false,
action = function(p0, node, _, _)
minetest.remove_node(p0)
minetest.sound_play("fake_fire_extinguish",
{pos = p0, max_hear_distance = 10, gain = 0.25})
end,
})
end
-- ========== --
-- Fire Nodes --
-- ========== --
minetest.register_node("fake_fire:fake_fire", {
description = "fake_fire",
description = "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}},
},
paramtype = "light",
is_ground_content = true,
inventory_image = 'fake_fire.png',
drawtype = "plantlike",
drawtype = "firelike",
buildable_to = true,
light_source = 14,
drop = '',
damage_per_second = 2*0.5,
drop = '', -- fire cannot be picked up
damage_per_second = 0, -- default 0 Recomended 2*0.5, --
groups = {dig_immediate=3,attached_node=1},
paramtype = "light",
walkable = false,
--sounds = minetest.sound_play("fire_small", {pos=cp, loop=true}),
on_punch = function (pos,node,puncher)
minetest.sound_play("fire_extinguish",
{pos = pos, gain = 1.0, max_hear_distance = 20,})
end
})
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"})
end
end,
on_punch = function(pos, node, puncher)
-- local name = minetest.get_node(pos).name
minetest.sound_play("fake_fire_extinguish",
{pos = pos, gain = 1.0, max_hear_distance = 10,})
end
})
-- new code --
-- ========== --
-- Fire Tools --
-- ========== --
-- found then changed to my likeing from flint mod --
local function get_nodedef_field(nodename, fieldname)
if not minetest.registered_nodes[nodename] then
return nil
end
return minetest.registered_nodes[nodename][fieldname]
end
-- Flint and Steel --
local function set_fake_fire(pointed_thing)
local n = minetest.env:get_node(pointed_thing.above)
if n.name ~= "" and n.name == "air" then
minetest.env:set_node(pointed_thing.above, {name="fake_fire:fake_fire"})
end
end
-- the flint and steel --
minetest.register_tool("fake_fire:flint_and_steel", {
description = "Flint and steel",
description = "Flint & Steel",
inventory_image = "flint_and_steel.png",
liquids_pointable = false,
stack_max = 1,
@ -64,51 +87,49 @@ minetest.register_tool("fake_fire:flint_and_steel", {
}
},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then
set_fake_fire(pointed_thing)
minetest.sound_play("",
{gain = 1.0, max_hear_distance = 2,})
itemstack:add_wear(65535/65)
return itemstack
end
end,
-- if item is pointing at a node then --
if pointed_thing.type == "node" then
-- set a value the degradeing --
wear = 65535/65
-- load function on line 6 --
set_fake_fire(pointed_thing,itemstack,wear)
return itemstack
end
end,
})
if minetest.get_modpath("fire") then
--override fire's flint and steel
minetest.override_item("fire:flint_and_steel", {
description = "Flint and Steel (disabled)",
on_use = function() return end,
groups={not_in_craft_guide=1, not_in_creative_inventory =1}
})
-- Old Flint and Steel --
--override craft reziepe
minetest.register_craft({
output = "fake_fire:flint_and_steel",
recipe = {
{"default:flint", "default:steel_ingot"}
--[[ Players cannot craft this item, they will need to spawn it via
"/give" or creative.
]]--
minetest.register_tool("fake_fire:old_flint_and_steel", {
description = "Never Ending Flint & Steel",
inventory_image = "flint_and_steel.png",
liquids_pointable = false,
stack_max = 1,
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=0,
groupcaps={
flamable = {uses=65, maxlevel=1},
}
})
end
-- Extinguish all flames quickly with water, snow, ice
minetest.register_abm({
nodenames = {"fake_fire:fake_fire"},
neighbors = {"group:puts_out_fire"},
interval = 3,
chance = 1,
catch_up = false,
action = function(pos, node)
minetest.remove_node(pos)
minetest.sound_play("fire_extinguish",
{pos = pos, gain = 1.0, max_hear_distance = 20,})
end,
},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then
-- this is so that it will never brake --
wear = 0
-- load function on line 6 --
set_fake_fire(pointed_thing, itemstack, wear)
return itemstack
end
end,
})
minetest.register_alias("fake_fire:flint", "default:flint")
-- =========== --
-- Fire crafts --
-- =========== --
minetest.register_craft({
output = "fake_fire:flint_and_steel",
@ -117,12 +138,3 @@ minetest.register_craft({
{"", "default:steel_ingot"},
}
})
-- 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. --

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.