Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minetest_game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
minetest_game
Commits
71a593ad
Commit
71a593ad
authored
9 years ago
by
Auke Kok
Committed by
Milan
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cherry-pick from github.com/minetest/minetest_game> Fire: move fire node removal out of ABM.
parent
1f191596
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mods/fire/init.lua
+18
-38
18 additions, 38 deletions
mods/fire/init.lua
with
18 additions
and
38 deletions
mods/fire/init.lua
+
18
−
38
View file @
71a593ad
...
...
@@ -28,14 +28,24 @@ minetest.register_node("fire:basic_flame", {
sunlight_propagates
=
true
,
damage_per_second
=
4
,
groups
=
{
igniter
=
2
,
dig_immediate
=
3
,
not_in_creative_inventory
=
1
},
on_timer
=
function
(
pos
)
local
f
=
minetest
.
find_node_near
(
pos
,
1
,
{
"group:flammable"
})
if
not
f
then
minetest
.
remove_node
(
pos
)
return
end
-- restart timer
return
true
end
,
drop
=
""
,
on_construct
=
function
(
pos
)
minetest
.
after
(
0
,
fire
.
on_flame_add_at
,
pos
)
minetest
.
get_node_timer
(
pos
):
start
(
math.random
(
30
,
60
))
minetest
.
after
(
0
,
fire
.
update_sounds_around
,
pos
)
end
,
on_destruct
=
function
(
pos
)
minetest
.
after
(
0
,
fire
.
on_flame_remove_at
,
pos
)
minetest
.
after
(
0
,
fire
.
update_sounds_around
,
pos
)
end
,
on_blast
=
function
()
...
...
@@ -169,32 +179,6 @@ function fire.update_sounds_around(pos)
end
-- Update fire sounds on flame node construct or destruct
function
fire
.
on_flame_add_at
(
pos
)
fire
.
update_sounds_around
(
pos
)
end
function
fire
.
on_flame_remove_at
(
pos
)
fire
.
update_sounds_around
(
pos
)
end
-- Return positions for flames around a burning node
function
fire
.
find_pos_for_flame_around
(
pos
)
return
minetest
.
find_node_near
(
pos
,
1
,
{
"air"
})
end
-- Detect nearby extinguishing nodes
function
fire
.
flame_should_extinguish
(
pos
)
return
minetest
.
find_node_near
(
pos
,
1
,
{
"group:puts_out_fire"
})
end
-- Extinguish all flames quickly with water, snow, ice
minetest
.
register_abm
({
...
...
@@ -239,31 +223,27 @@ else
catch_up
=
false
,
action
=
function
(
p0
,
node
,
_
,
_
)
-- If there is water or stuff like that around node, don't ignite
if
fire
.
flame_should_extinguish
(
p0
)
then
if
minetest
.
find_node_near
(
p0
,
1
,
{
"group:puts_out_fire"
}
)
then
return
end
local
p
=
fire
.
find_pos_for_flame_around
(
p0
)
local
p
=
minetest
.
find_node_near
(
p0
,
1
,
{
"air"
}
)
if
p
then
minetest
.
set_node
(
p
,
{
name
=
"fire:basic_flame"
})
end
end
,
})
-- Remove
basic flames and
flammable nodes
-- Remove flammable nodes
minetest
.
register_abm
({
nodenames
=
{
"fire:basic_flame"
},
neighbors
=
"group:flammable"
,
interval
=
5
,
chance
=
6
,
chance
=
18
,
catch_up
=
false
,
action
=
function
(
p0
,
node
,
_
,
_
)
-- If there are no flammable nodes around flame, remove flame
local
p
=
minetest
.
find_node_near
(
p0
,
1
,
{
"group:flammable"
})
if
not
p
then
minetest
.
remove_node
(
p0
)
return
end
if
math.random
(
1
,
3
)
==
1
then
if
p
then
-- remove flammable nodes around flame
local
node
=
minetest
.
get_node
(
p
)
local
def
=
minetest
.
registered_nodes
[
node
.
name
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment