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
c824d691
Commit
c824d691
authored
8 years ago
by
Fernando Carmona Varo
Committed by
paramat
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fire / tnt: Make flint-and-steel use node on_ignite functions
Add on_ignite functions to tnt, gunpowder, coalblock.
parent
c7e2d594
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
game_api.txt
+8
-0
8 additions, 0 deletions
game_api.txt
mods/fire/init.lua
+20
-33
20 additions, 33 deletions
mods/fire/init.lua
mods/tnt/init.lua
+8
-2
8 additions, 2 deletions
mods/tnt/init.lua
with
36 additions
and
35 deletions
game_api.txt
+
8
−
0
View file @
c824d691
...
...
@@ -227,6 +227,14 @@ New node def property:
* Called when fire attempts to remove a burning node.
* `pos` Position of the burning node.
`on_ignite(pos, igniter)`
* Called when Flint and steel (or a mod defined ignitor) is used on a node.
Defining it may prevent the default action (spawning flames) from triggering.
* `pos` Position of the ignited node.
* `igniter` Player that used the tool, when available.
Give Initial Stuff API
----------------------
...
...
This diff is collapsed.
Click to expand it.
mods/fire/init.lua
+
20
−
33
View file @
c824d691
...
...
@@ -95,38 +95,20 @@ minetest.register_tool("fire:flint_and_steel", {
itemstack
:
add_wear
(
1000
)
if
pt
.
type
==
"node"
then
local
node_under
=
minetest
.
get_node
(
pt
.
under
).
name
local
is_coalblock
=
node_under
==
"default:coalblock"
local
is_tnt
=
node_under
==
"tnt:tnt"
local
is_gunpowder
=
node_under
==
"tnt:gunpowder"
if
minetest
.
get_item_group
(
node_under
,
"flammable"
)
>=
1
or
is_coalblock
or
is_tnt
or
is_gunpowder
then
local
flame_pos
=
pt
.
above
if
is_coalblock
then
flame_pos
=
{
x
=
pt
.
under
.
x
,
y
=
pt
.
under
.
y
+
1
,
z
=
pt
.
under
.
z
}
elseif
is_tnt
or
is_gunpowder
then
flame_pos
=
pt
.
under
end
if
minetest
.
get_node
(
flame_pos
).
name
==
"air"
or
is_tnt
or
is_gunpowder
then
local
player_name
=
user
:
get_player_name
()
if
not
minetest
.
is_protected
(
flame_pos
,
player_name
)
then
if
is_coalblock
then
minetest
.
set_node
(
flame_pos
,
{
name
=
"fire:permanent_flame"
})
elseif
is_tnt
then
minetest
.
set_node
(
flame_pos
,
{
name
=
"tnt:tnt_burning"
})
elseif
is_gunpowder
then
minetest
.
set_node
(
flame_pos
,
{
name
=
"tnt:gunpowder_burning"
})
else
minetest
.
set_node
(
flame_pos
,
{
name
=
"fire:basic_flame"
})
end
else
minetest
.
chat_send_player
(
player_name
,
"This area is protected"
)
end
end
local
nodedef
=
minetest
.
registered_nodes
[
node_under
]
if
not
nodedef
then
return
end
local
player_name
=
user
:
get_player_name
()
if
minetest
.
is_protected
(
pt
.
under
,
player_name
)
then
minetest
.
chat_send_player
(
player_name
,
"This area is protected"
)
return
end
if
nodedef
.
on_ignite
then
nodedef
.
on_ignite
(
pt
.
under
,
user
)
elseif
minetest
.
get_item_group
(
node_under
,
"flammable"
)
>=
1
and
minetest
.
get_node
(
pt
.
above
).
name
==
"air"
then
minetest
.
set_node
(
pt
.
above
,
{
name
=
"fire:basic_flame"
})
end
end
if
not
minetest
.
setting_getbool
(
"creative_mode"
)
then
...
...
@@ -153,9 +135,14 @@ minetest.override_item("default:coalblock", {
minetest
.
remove_node
(
pos
)
end
end
,
on_ignite
=
function
(
pos
,
igniter
)
local
flame_pos
=
{
x
=
pos
.
x
,
y
=
pos
.
y
+
1
,
z
=
pos
.
z
}
if
minetest
.
get_node
(
flame_pos
).
name
==
"air"
then
minetest
.
set_node
(
flame_pos
,
{
name
=
"fire:permanent_flame"
})
end
end
,
})
-- Get sound area of position
fire
.
D
=
6
-- size of sound areas
...
...
This diff is collapsed.
Click to expand it.
mods/tnt/init.lua
+
8
−
2
View file @
c824d691
...
...
@@ -418,7 +418,10 @@ minetest.register_node("tnt:gunpowder", {
end
,
on_burn
=
function
(
pos
)
minetest
.
set_node
(
pos
,
{
name
=
"tnt:gunpowder_burning"
})
end
end
,
on_ignite
=
function
(
pos
,
igniter
)
minetest
.
set_node
(
pos
,
{
name
=
"tnt:gunpowder_burning"
})
end
,
})
minetest
.
register_node
(
"tnt:gunpowder_burning"
,
{
...
...
@@ -563,7 +566,10 @@ function tnt.register_tnt(def)
},
on_burn
=
function
(
pos
)
minetest
.
set_node
(
pos
,
{
name
=
name
..
"_burning"
})
end
end
,
on_ignite
=
function
(
pos
,
igniter
)
minetest
.
set_node
(
pos
,
{
name
=
name
..
"_burning"
})
end
,
})
end
...
...
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