-
Notifications
You must be signed in to change notification settings - Fork 1
/
fire_extinguisher.lua
41 lines (36 loc) · 1.4 KB
/
fire_extinguisher.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
minetest.register_tool("fire_realism:fire_extinguisher", {
description = "Fire Extinguisher",
inventory_image = "fire_realism_fire_extinguisher.png",
on_use = function(itemstack,user,pointed_thing)
local pos = pointed_thing.above
if pos ~= nil then
local radius = 3
local minp = {x=pos.x+radius,y=pos.y+radius,z=pos.z+radius}
local maxp = {x=pos.x-radius,y=pos.y-radius,z=pos.z-radius}
local hot_ash = minetest.find_nodes_in_area(minp,maxp,{"group:hot_ash"})
local fire = minetest.find_nodes_in_area(minp,maxp,{"fire:basic_flame","fire:permanent_flame"})
for _, _pos in ipairs(hot_ash) do
local node = minetest.registered_nodes[minetest.get_node(_pos).name]
local ash_type = fire_realism.split_string(node.ash_type,":")[2]
minetest.swap_node(_pos,{name="fire_realism:ash_and_"..ash_type})
end
for _, _pos in ipairs(fire) do
minetest.swap_node(_pos,{name="air"})
end
end
if not core.setting_getbool("creative_mode") then
local usage = 6553.5
itemstack:add_wear(usage)
end
return itemstack
end
})
minetest.register_craft({
type = "shaped",
output = "fire_realism:fire_extinguisher",
recipe = {
{"dye:red", "default:steel_ingot", "dye:red"},
{"default:steel_ingot", "bucket:bucket_water", "default:steel_ingot"},
{"dye:red", "default:steel_ingot", "dye:red"}
}
})