Start initial stub work on fire.

This commit is contained in:
Aaron Suen 2018-11-04 22:03:22 -05:00
parent 8a316dea75
commit bd526122e8
9 changed files with 102 additions and 3 deletions

10
mods/nc_fire/api.lua Normal file
View File

@ -0,0 +1,10 @@
--[[
node_def = {
group = { flammable = 1 }
fire_ignite = total heat intensity required to ignite
fire_intensity = heat level released (0.5x below, 2x above)
fire_fuel = amount of fuel contained (in intensity-seconds)
on_heat = function(pos, node, intensity, frompos) ... end
}
solo-inv take contained items into account!
--]]

1
mods/nc_fire/depends.txt Normal file
View File

@ -0,0 +1 @@
nc_api

10
mods/nc_fire/init.lua Normal file
View File

@ -0,0 +1,10 @@
-- LUALOCALS < ---------------------------------------------------------
local dofile, minetest
= dofile, minetest
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local path = minetest.get_modpath(modname)
dofile(path .. "/api.lua")
dofile(path .. "/node.lua")

80
mods/nc_fire/node.lua Normal file
View File

@ -0,0 +1,80 @@
-- LUALOCALS < ---------------------------------------------------------
local minetest
= minetest
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
minetest.register_node(modname .. ":fire", {
description = "Fire",
drawtype = "firelike",
visual_scale = 1.5,
tiles = {modname .. "_fire.png"},
paramtype = "light",
light_source = 12,
damage_per_second = 2,
propagates_sunlight = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true
})
minetest.register_node(modname .. ":fuel", {
description = "Burning Embers",
tiles = {modname .. "_fuel.png"},
paramtype = "light",
light_source = 6,
groups = { falling_node = 1 },
drop = "",
diggable = false,
on_punch = function(pos, node, puncher)
puncher:set_hp(puncher:get_hp() - 1)
end
})
minetest.register_node(modname .. ":ash", {
description = "Ash",
tiles = {modname .. "_ash.png"},
groups = { falling_node = 1, crumbly = 3 }
})
minetest.register_abm({
label = "Fire Requires Fuel",
interval = 1,
chance = 1,
nodenames = {modname .. ":fire"},
action = function(pos)
local node = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z })
if node.name == modname .. ":fuel" then return end
node = minetest.get_node({x = pos.x + 1, y = pos.y, z = pos.z })
if node.name == modname .. ":fuel" then return end
node = minetest.get_node({x = pos.x - 1, y = pos.y, z = pos.z })
if node.name == modname .. ":fuel" then return end
node = minetest.get_node({x = pos.x, y = pos.y, z = pos.z + 1})
if node.name == modname .. ":fuel" then return end
node = minetest.get_node({x = pos.x, y = pos.y, z = pos.z - 1})
if node.name == modname .. ":fuel" then return end
return minetest.remove_node(pos)
end
})
local function mkfire(pos, dx, dy, dz)
pos = {x = pos.x + dx, y = pos.y + dy, z = pos.z + dz}
if minetest.get_node(pos).name ~= "air" then return end
return minetest.set_node(pos, {name = modname .. ":fire"})
end
minetest.register_abm({
label = "Fuel Spawns Fire",
interval = 1,
chance = 1,
nodenames = {modname .. ":fuel"},
neighbors = {"air"},
action = function(pos)
mkfire(pos, 0, 1, 0)
mkfire(pos, 1, 0, 0)
mkfire(pos, -1, 0, 0)
mkfire(pos, 0, 0, 1)
mkfire(pos, 0, 0, -1)
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

View File

@ -3,8 +3,6 @@ local minetest
= minetest
-- LUALOCALS > ---------------------------------------------------------
local minetest = minetest
local health_bar_definition =
{
hud_elem_type = "statbar",

View File

@ -7,7 +7,7 @@ minetest.register_on_joinplayer(function(player)
player:set_properties({
visual = "upright_sprite",
visual_size = { x = 1, y = 2 },
textures = { "nc_player_front.png", "nc_player_back.png" },
textures = { "nc_player_front.png", "nc_player_back.png" }
})
player:get_inventory():set_size("main", 8)