Add flare gun.
This commit is contained in:
parent
357be42a0a
commit
193ad7e7ac
6 changed files with 118 additions and 1 deletions
13
abms.lua
13
abms.lua
|
@ -313,6 +313,19 @@ end)
|
||||||
-- destruction
|
-- destruction
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"fun_caves:flare",},
|
||||||
|
interval = 5,
|
||||||
|
chance = 10,
|
||||||
|
action = function(pos, node)
|
||||||
|
if not (pos and node) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"fun_caves:hot_cobble",},
|
nodenames = {"fun_caves:hot_cobble",},
|
||||||
neighbors = {"group:water"},
|
neighbors = {"group:water"},
|
||||||
|
|
6
init.lua
6
init.lua
|
@ -187,7 +187,11 @@ dofile(fun_caves.path .. "/fungal_tree.lua")
|
||||||
dofile(fun_caves.path .. "/wallhammer.lua")
|
dofile(fun_caves.path .. "/wallhammer.lua")
|
||||||
dofile(fun_caves.path .. "/mapgen.lua")
|
dofile(fun_caves.path .. "/mapgen.lua")
|
||||||
dofile(fun_caves.path .. "/wooden_buckets.lua")
|
dofile(fun_caves.path .. "/wooden_buckets.lua")
|
||||||
dofile(fun_caves.path .. "/spec_bomb.lua")
|
|
||||||
|
if minetest.get_modpath('tnt') then
|
||||||
|
dofile(fun_caves.path .. "/spec_bomb.lua")
|
||||||
|
end
|
||||||
|
|
||||||
dofile(fun_caves.path .. "/elixir.lua") -- must go after all items are registered
|
dofile(fun_caves.path .. "/elixir.lua") -- must go after all items are registered
|
||||||
dofile(fun_caves.path .. "/chat.lua")
|
dofile(fun_caves.path .. "/chat.lua")
|
||||||
|
|
||||||
|
|
|
@ -397,3 +397,102 @@ minetest.register_craft({
|
||||||
{'', 'default:steelblock', 'default:coalblock'},
|
{'', 'default:steelblock', 'default:coalblock'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
local function flares(player)
|
||||||
|
local dir = player:get_look_dir()
|
||||||
|
local pos = player:getpos()
|
||||||
|
if not pos then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pos.x = pos.x + dir.x * 10
|
||||||
|
pos.y = pos.y + dir.y * 10
|
||||||
|
pos.z = pos.z + dir.z * 10
|
||||||
|
pos = vector.round(pos)
|
||||||
|
|
||||||
|
local air = minetest.get_content_id('air')
|
||||||
|
local flare = minetest.get_content_id('fun_caves:flare')
|
||||||
|
local vm = minetest.get_voxel_manip()
|
||||||
|
if not vm then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local r = 8
|
||||||
|
local minp = vector.subtract(pos, r)
|
||||||
|
local maxp = vector.add(pos, r)
|
||||||
|
local emin, emax = vm:read_from_map(minp, maxp)
|
||||||
|
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
||||||
|
local data = vm:get_data()
|
||||||
|
local count = 0
|
||||||
|
for i = 1, 50 do
|
||||||
|
local x = pos.x + math.random(2 * r + 1) - r - 1
|
||||||
|
local y = pos.y + math.random(2 * r + 1) - r - 1
|
||||||
|
local z = pos.z + math.random(2 * r + 1) - r - 1
|
||||||
|
local ivm = area:index(x, y, z)
|
||||||
|
if data[ivm] == air then
|
||||||
|
data[ivm] = flare
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vm:set_data(data)
|
||||||
|
vm:calc_lighting(minp, maxp)
|
||||||
|
vm:update_liquids()
|
||||||
|
vm:write_to_map()
|
||||||
|
vm:update_map()
|
||||||
|
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("fun_caves:flare", {
|
||||||
|
description = "Fungal tree fruit",
|
||||||
|
drawtype = "plantlike",
|
||||||
|
visual_scale = 0.75,
|
||||||
|
tiles = {"fun_caves_flare.png"},
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
light_source = 15,
|
||||||
|
walkable = false,
|
||||||
|
diggable = false,
|
||||||
|
pointable = false,
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_tool("fun_caves:flare_gun", {
|
||||||
|
description = "Flare Gun",
|
||||||
|
inventory_image = "fun_caves_flare_gun.png",
|
||||||
|
tool_capabilities = {
|
||||||
|
full_punch_interval = 1.2,
|
||||||
|
max_drop_level=0,
|
||||||
|
groupcaps={
|
||||||
|
snappy={times={[2]=1.6, [3]=0.40}, uses=10, maxlevel=1},
|
||||||
|
},
|
||||||
|
damage_groups = {fleshy=2},
|
||||||
|
},
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
if not user then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local count = flares(user)
|
||||||
|
itemstack:add_wear(count * 400)
|
||||||
|
return itemstack
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'fun_caves:flare_gun',
|
||||||
|
recipe = {
|
||||||
|
{'', '', ''},
|
||||||
|
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||||
|
{'', 'tnt:gunpowder', 'group:stick'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'fun_caves:flare_gun',
|
||||||
|
recipe = {
|
||||||
|
{'', '', ''},
|
||||||
|
{'', 'fun_caves:flare_gun', ''},
|
||||||
|
{'', 'tnt:gunpowder', ''},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
BIN
textures/fun_caves_flare.png
Normal file
BIN
textures/fun_caves_flare.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 B |
BIN
textures/fun_caves_flare_gun.png
Normal file
BIN
textures/fun_caves_flare_gun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
|
@ -13,3 +13,4 @@ The pyramid and translocator textures are copied from the default sandstone and
|
||||||
Firework 2: William Crochot (cc-by-sa 4): https://en.wikipedia.org/wiki/File:Feu_d'artifice_-_333.jpg
|
Firework 2: William Crochot (cc-by-sa 4): https://en.wikipedia.org/wiki/File:Feu_d'artifice_-_333.jpg
|
||||||
Apple pie: Dan Parsons (cc-by-sa 2): https://en.wikipedia.org/wiki/File:Apple_pie.jpg
|
Apple pie: Dan Parsons (cc-by-sa 2): https://en.wikipedia.org/wiki/File:Apple_pie.jpg
|
||||||
Onion: Colin (cc-by-sa 3): https://en.wikipedia.org/wiki/File:Red_Onion_on_White.JPG
|
Onion: Colin (cc-by-sa 3): https://en.wikipedia.org/wiki/File:Red_Onion_on_White.JPG
|
||||||
|
Flare Gun: Billlion (cc-by-sa 3): https://en.wikipedia.org/wiki/File:Molins_Number_1_signal_Pistol.jpg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue