2017-02-01 17:31:27 +02:00
-- Flint and Steel
minetest.register_tool ( " mcl_fire:flint_and_steel " , {
description = " Flint and Steel " ,
2017-08-17 05:12:34 +03:00
_doc_items_longdesc = " Flint and steel is a tool to start fires, ignite blocks and open portals. " ,
_doc_items_usagehelp = " Rightclick the surface of a block to attempt to light a fire in front of it. On netherrack it will start an eternal fire. Using it on TNT will ignite it. To open a Nether portal, place an upright frame of obsidian with a length of 4 and a height of 5 blocks, leaving only air in the center. After placing this frame, use the flint and steel on inside of the frame. " ,
2017-02-01 17:31:27 +02:00
inventory_image = " mcl_fire_flint_and_steel.png " ,
liquids_pointable = false ,
stack_max = 1 ,
groups = { tool = 1 } ,
2017-03-11 03:51:31 +02:00
on_place = function ( itemstack , user , pointed_thing )
2017-07-24 20:57:37 +03:00
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node ( pointed_thing.under )
if user and not user : get_player_control ( ) . sneak then
if minetest.registered_nodes [ node.name ] and minetest.registered_nodes [ node.name ] . on_rightclick then
return minetest.registered_nodes [ node.name ] . on_rightclick ( pointed_thing.under , node , user , itemstack ) or itemstack
end
end
2017-02-19 21:23:33 +02:00
local idef = itemstack : get_definition ( )
2017-02-19 23:58:51 +02:00
minetest.sound_play (
" fire_flint_and_steel " ,
{ pos = pointed_thing.above , gain = 0.5 , max_hear_distance = 8 }
)
2017-05-09 18:49:38 +03:00
local used = false
2017-02-01 17:31:27 +02:00
if pointed_thing.type == " node " then
2017-05-09 18:49:38 +03:00
local nodedef = minetest.registered_nodes [ minetest.get_node ( pointed_thing.under ) . name ]
2017-06-29 14:02:53 +03:00
if nodedef and nodedef._on_ignite then
2017-08-17 05:12:34 +03:00
nodedef._on_ignite ( user , pointed_thing )
2017-02-01 17:31:27 +02:00
else
2017-02-01 17:43:05 +02:00
mcl_fire.set_fire ( pointed_thing )
2017-02-01 17:31:27 +02:00
end
2017-05-09 18:49:38 +03:00
used = true
2017-02-01 17:31:27 +02:00
end
2017-02-19 21:23:33 +02:00
if itemstack : get_count ( ) == 0 and idef.sound and idef.sound . breaks then
minetest.sound_play ( idef.sound . breaks , { pos = user : getpos ( ) , gain = 0.5 } )
end
2017-08-09 17:17:00 +03:00
if not minetest.settings : get_bool ( " creative_mode " ) and used == true then
2017-05-09 18:49:38 +03:00
itemstack : add_wear ( 65535 / 65 ) -- 65 uses
end
2017-02-01 17:45:49 +02:00
return itemstack
2017-02-01 17:31:27 +02:00
end ,
2017-02-19 21:23:33 +02:00
sound = { breaks = " default_tool_breaks " } ,
2017-02-01 17:31:27 +02:00
} )
minetest.register_craft ( {
type = ' shapeless ' ,
2017-02-01 17:39:51 +02:00
output = ' mcl_fire:flint_and_steel ' ,
2017-02-11 22:14:40 +02:00
recipe = { ' mcl_core:iron_ingot ' , ' mcl_core:flint ' } ,
2017-02-01 17:31:27 +02:00
} )