Replace minetest.env: with minetest.
This commit is contained in:
parent
d35ee89674
commit
d5d51a035b
26
init.lua
26
init.lua
@ -47,7 +47,7 @@ end
|
|||||||
function fire.update_sounds_around(pos)
|
function fire.update_sounds_around(pos)
|
||||||
local p0, p1 = fire.get_area_p0p1(pos)
|
local p0, p1 = fire.get_area_p0p1(pos)
|
||||||
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
|
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
|
||||||
local flames_p = minetest.env:find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
local flames_p = minetest.find_nodes_in_area(p0, p1, {"fire:basic_flame"})
|
||||||
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
--print("number of flames at "..minetest.pos_to_string(p0).."/"
|
||||||
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
|
||||||
local should_have_sound = (#flames_p > 0)
|
local should_have_sound = (#flames_p > 0)
|
||||||
@ -91,15 +91,15 @@ function fire.on_flame_remove_at(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function fire.find_pos_for_flame_around(pos)
|
function fire.find_pos_for_flame_around(pos)
|
||||||
return minetest.env:find_node_near(pos, 1, {"air"})
|
return minetest.find_node_near(pos, 1, {"air"})
|
||||||
end
|
end
|
||||||
|
|
||||||
function fire.flame_should_extinguish(pos)
|
function fire.flame_should_extinguish(pos)
|
||||||
if minetest.setting_getbool("disable_fire") then return true end
|
if minetest.setting_getbool("disable_fire") then return true end
|
||||||
--return minetest.env:find_node_near(pos, 1, {"group:puts_out_fire"})
|
--return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
|
||||||
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
|
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
|
||||||
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
||||||
local ps = minetest.env:find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
|
local ps = minetest.find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
|
||||||
return (#ps ~= 0)
|
return (#ps ~= 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
local p = fire.find_pos_for_flame_around(p0)
|
local p = fire.find_pos_for_flame_around(p0)
|
||||||
if p then
|
if p then
|
||||||
minetest.env:set_node(p, {name="fire:basic_flame"})
|
minetest.set_node(p, {name="fire:basic_flame"})
|
||||||
fire.on_flame_add_at(p)
|
fire.on_flame_add_at(p)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -134,7 +134,7 @@ minetest.register_abm({
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local d = reg.groups.igniter
|
local d = reg.groups.igniter
|
||||||
local p = minetest.env:find_node_near(p0, d, {"group:flammable"})
|
local p = minetest.find_node_near(p0, d, {"group:flammable"})
|
||||||
if p then
|
if p then
|
||||||
-- If there is water or stuff like that around flame, don't ignite
|
-- If there is water or stuff like that around flame, don't ignite
|
||||||
if fire.flame_should_extinguish(p) then
|
if fire.flame_should_extinguish(p) then
|
||||||
@ -142,7 +142,7 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
local p2 = fire.find_pos_for_flame_around(p)
|
local p2 = fire.find_pos_for_flame_around(p)
|
||||||
if p2 then
|
if p2 then
|
||||||
minetest.env:set_node(p2, {name="fire:basic_flame"})
|
minetest.set_node(p2, {name="fire:basic_flame"})
|
||||||
fire.on_flame_add_at(p2)
|
fire.on_flame_add_at(p2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -157,7 +157,7 @@ minetest.register_abm({
|
|||||||
action = function(p0, node, _, _)
|
action = function(p0, node, _, _)
|
||||||
-- If there is water or stuff like that around flame, remove flame
|
-- If there is water or stuff like that around flame, remove flame
|
||||||
if fire.flame_should_extinguish(p0) then
|
if fire.flame_should_extinguish(p0) then
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
fire.on_flame_remove_at(p0)
|
fire.on_flame_remove_at(p0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -166,25 +166,25 @@ minetest.register_abm({
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- If there are no flammable nodes around flame, remove flame
|
-- If there are no flammable nodes around flame, remove flame
|
||||||
if not minetest.env:find_node_near(p0, 1, {"group:flammable"}) then
|
if not minetest.find_node_near(p0, 1, {"group:flammable"}) then
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
fire.on_flame_remove_at(p0)
|
fire.on_flame_remove_at(p0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if math.random(1,4) == 1 then
|
if math.random(1,4) == 1 then
|
||||||
-- remove a flammable node around flame
|
-- remove a flammable node around flame
|
||||||
local p = minetest.env:find_node_near(p0, 1, {"group:flammable"})
|
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
|
||||||
if p then
|
if p then
|
||||||
-- If there is water or stuff like that around flame, don't remove
|
-- If there is water or stuff like that around flame, don't remove
|
||||||
if fire.flame_should_extinguish(p0) then
|
if fire.flame_should_extinguish(p0) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.env:remove_node(p)
|
minetest.remove_node(p)
|
||||||
nodeupdate(p)
|
nodeupdate(p)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- remove flame
|
-- remove flame
|
||||||
minetest.env:remove_node(p0)
|
minetest.remove_node(p0)
|
||||||
fire.on_flame_remove_at(p0)
|
fire.on_flame_remove_at(p0)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user