diff --git a/abms.lua b/abms.lua index 74fd235..2f12bd3 100644 --- a/abms.lua +++ b/abms.lua @@ -313,6 +313,19 @@ end) -- 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({ nodenames = {"fun_caves:hot_cobble",}, neighbors = {"group:water"}, diff --git a/init.lua b/init.lua index f9777b2..c11bbd1 100644 --- a/init.lua +++ b/init.lua @@ -187,7 +187,11 @@ dofile(fun_caves.path .. "/fungal_tree.lua") dofile(fun_caves.path .. "/wallhammer.lua") dofile(fun_caves.path .. "/mapgen.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 .. "/chat.lua") diff --git a/spec_bomb.lua b/spec_bomb.lua index b5d6675..0b03f87 100644 --- a/spec_bomb.lua +++ b/spec_bomb.lua @@ -397,3 +397,102 @@ minetest.register_craft({ {'', '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', ''}, + } +}) diff --git a/textures/fun_caves_flare.png b/textures/fun_caves_flare.png new file mode 100644 index 0000000..e2e045b Binary files /dev/null and b/textures/fun_caves_flare.png differ diff --git a/textures/fun_caves_flare_gun.png b/textures/fun_caves_flare_gun.png new file mode 100644 index 0000000..c7dc74b Binary files /dev/null and b/textures/fun_caves_flare_gun.png differ diff --git a/textures/image_credits.txt b/textures/image_credits.txt index 7ff3960..8107e32 100644 --- a/textures/image_credits.txt +++ b/textures/image_credits.txt @@ -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 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 +Flare Gun: Billlion (cc-by-sa 3): https://en.wikipedia.org/wiki/File:Molins_Number_1_signal_Pistol.jpg