diff --git a/.luacheckrc b/.luacheckrc index 93c90f8..529088b 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -19,6 +19,9 @@ read_globals = { -- MC2 "mcl_sounds", + -- Nodecore + "nodecore", + -- Other mods "stairsplus", "toolranks", } diff --git a/compat/mcl2.lua b/compat/mcl2.lua deleted file mode 100644 index a146ec4..0000000 --- a/compat/mcl2.lua +++ /dev/null @@ -1,192 +0,0 @@ -local S - -if minetest.get_translator ~= nil then - S = minetest.get_translator(minetest.get_current_modname()) -else - S = function(str) - return(str) - end -end - -for _, item in pairs({"lavastuff:sword", "lavastuff:pick", "lavastuff:axe", "lavastuff:shovel"}) do - local itype = item:sub(item:find(":")+1) - local mcldef = table.copy(minetest.registered_items[("mcl_tools:%s_diamond"):format(itype)]) - local groups = table.copy(minetest.registered_items[item].groups) - - mcldef.tool_capabilities.damage_groups.fleshy = mcldef.tool_capabilities.damage_groups.fleshy + 1 - mcldef.tool_capabilities.full_punch_interval = mcldef.tool_capabilities.full_punch_interval - 0.1 - groups.dig_speed_class = mcldef.groups.dig_speed_class - - minetest.override_item(item, { - tool_capabilities = mcldef.tool_capabilities, - groups = groups, - wield_scale = vector.new(1.8, 1.8, 1), - _repair_material = "lavastuff:ingot", - }) -end - -minetest.override_item("lavastuff:block", { - stack_max = 64, - groups = {pickaxey=3, building_block=1}, - sounds = mcl_sounds.node_sound_stone_defaults(), - _mcl_blast_resistance = 6, - _mcl_hardness = 4, -}) - -for _, item in pairs({"lavastuff:ingot", "lavastuff:orb"}) do - minetest.override_item(item, { - stack_max = 64, - }) -end - -minetest.register_tool("lavastuff:helmet",{ - description = S("Lava Helmet"), - inventory_image = "lavastuff_inv_helmet.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_head=1, mcl_armor_points=3, mcl_armor_uses=600, mcl_armor_toughness=3}, - _repair_material = "lavastuff:ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("lavastuff:chestplate", { - description = S("Lava Chestplate"), - inventory_image = "lavastuff_inv_chestplate.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_torso=1, mcl_armor_points=8, mcl_armor_uses=600, mcl_armor_toughness=3}, - _repair_material = "lavastuff:ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("lavastuff:leggings", { - description = S("Lava Leggings"), - inventory_image = "lavastuff_inv_leggings.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_legs=1, mcl_armor_points=6, mcl_armor_uses=600, mcl_armor_toughness=3}, - _repair_material = "lavastuff:ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - -minetest.register_tool("lavastuff:boots", { - description = S("Lava Boots"), - inventory_image = "lavastuff_inv_boots.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_feet=1, mcl_armor_points=3, mcl_armor_uses=600, mcl_armor_toughness=3}, - _repair_material = "lavastuff:ingot", - sounds = { - _mcl_armor_equip = "mcl_armor_equip_diamond", - _mcl_armor_unequip = "mcl_armor_unequip_diamond", - }, - on_place = armor.on_armor_use, - on_secondary_use = armor.on_armor_use, -}) - --- --- Ingot craft --- - -minetest.register_craft({ - type = "shapeless", - output = "lavastuff:ingot 2", - recipe = {"mcl_mobitems:blaze_rod", "lavastuff:orb"} -}) - --- --- Orb craft --- - -minetest.register_craft({ - output = "lavastuff:orb", - recipe = { - {"mcl_mobitems:blaze_powder", "mcl_mobitems:magma_cream", "mcl_mobitems:blaze_powder"}, - {"mcl_mobitems:magma_cream", "mcl_buckets:bucket_lava", "mcl_mobitems:magma_cream"}, - {"", "mcl_mobitems:magma_cream", ""} - }, - replacements = {{"mcl_buckets:bucket_lava", "mcl_buckets:bucket_empty"}} -}) - --- --- Tool crafts --- - -minetest.register_craft({ - output = "lavastuff:sword", - recipe = { - {"lavastuff:ingot"}, - {"lavastuff:ingot"}, - {"mcl_core:iron_ingot"}, - } -}) - -minetest.register_craft({ - output = "lavastuff:pick", - recipe = { - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"", "mcl_core:iron_ingot", ""}, - {"", "mcl_core:iron_ingot", ""}, - } -}) - -minetest.register_craft({ - output = "lavastuff:shovel", - recipe = { - {"lavastuff:ingot"}, - {"mcl_core:iron_ingot"}, - {"mcl_core:iron_ingot"}, - } -}) - -minetest.register_craft({ - output = "lavastuff:axe", - recipe = { - {"lavastuff:ingot", "lavastuff:ingot", ""}, - {"lavastuff:ingot", "mcl_core:iron_ingot", ""}, - {"", "mcl_core:iron_ingot", ""}, - } -}) - --- --- Block crafts --- - -minetest.register_craft({ - type = "shapeless", - output = "lavastuff:ingot 9", - recipe = {"lavastuff:block"} -}) - -minetest.register_craft({ - output = "lavastuff:block", - recipe = { - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - } -}) - --- --- Lava in a Bottle craft --- - -minetest.register_craft({ - output = "lavastuff:lava_in_a_bottle", - recipe = { - {"", "mcl_buckets:bucket_lava"}, - {"", "mcl_potions:glass_bottle"}, - }, - replacements = {{"mcl_buckets:bucket_lava", "mcl_buckets:bucket_empty"}} -}) diff --git a/compat/mtg.lua b/compat/mtg.lua deleted file mode 100644 index 9563442..0000000 --- a/compat/mtg.lua +++ /dev/null @@ -1,172 +0,0 @@ -local S - -if minetest.get_translator ~= nil then - S = minetest.get_translator(minetest.get_current_modname()) -else - S = function(str) - return(str) - end -end - --- Armor --- - -if minetest.get_modpath("3d_armor") then - armor.materials.lava = "lavastuff:ingot" - armor.config.material_lava = true - - armor:register_armor("lavastuff:helmet_lava", { - description = S("Lava Helmet"), - inventory_image = "lavastuff_inv_helmet.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_head=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=15}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - minetest.register_alias("lavastuff:helmet", "lavastuff:helmet_lava") - - armor:register_armor("lavastuff:chestplate_lava", { - description = S("Lava Chestplate"), - inventory_image = "lavastuff_inv_chestplate.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_torso=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=20}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - minetest.register_alias("lavastuff:chestplate", "lavastuff:chestplate_lava") - - armor:register_armor("lavastuff:leggings_lava", { - description = S("Lava Leggings"), - inventory_image = "lavastuff_inv_leggings.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_legs=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=20}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - minetest.register_alias("lavastuff:leggings", "lavastuff:leggings_lava") - - armor:register_armor("lavastuff:boots_lava", { - description = S("Lava Boots"), - inventory_image = "lavastuff_inv_boots.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_feet=1, armor_heal=12, armor_use=100, armor_fire=10, physics_jump=0.5, physics_speed = 1}, - armor_groups = {fleshy=15}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - minetest.register_alias("lavastuff:boots", "lavastuff:boots_lava") - - if minetest.get_modpath("shields") then - armor:register_armor("lavastuff:shield_lava", { - description = S("Lava Shield"), - inventory_image = "lavastuff_inven_shield.png", - light_source = 7, -- Texture will have a glow when dropped - groups = {armor_shield=1, armor_heal=12, armor_use=100, armor_fire=10}, - armor_groups = {fleshy=20}, - damage_groups = {cracky=2, snappy=1, level=3}, - wear = 0, - }) - minetest.register_alias("lavastuff:shield", "lavastuff:shield_lava") - end -end - --- --- Ingot craft --- - -minetest.register_craft({ - type = "shapeless", - output = "lavastuff:ingot 2", - recipe = {"default:mese_crystal", "lavastuff:orb"} -}) - --- --- Orb craft --- - -if not minetest.get_modpath("mobs_monster") then - minetest.register_craft({ - output = "lavastuff:orb", - recipe = { - {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"}, - {"default:mese_crystal", "bucket:bucket_lava", "default:mese_crystal"}, - {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"} - }, - replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}} - }) -end - --- --- Tool crafts --- - -minetest.register_craft({ - output = "lavastuff:sword", - recipe = { - {"lavastuff:ingot"}, - {"lavastuff:ingot"}, - {"default:obsidian_shard"}, - } -}) - -minetest.register_craft({ - output = "lavastuff:pick", - recipe = { - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"", "default:obsidian_shard", ""}, - {"", "default:obsidian_shard", ""}, - } -}) - -minetest.register_craft({ - output = "lavastuff:shovel", - recipe = { - {"lavastuff:ingot"}, - {"default:obsidian_shard"}, - {"default:obsidian_shard"}, - } -}) - -minetest.register_craft({ - output = "lavastuff:axe", - recipe = { - {"lavastuff:ingot", "lavastuff:ingot", ""}, - {"lavastuff:ingot", "default:obsidian_shard", ""}, - {"", "default:obsidian_shard", ""}, - } -}) - --- --- Block crafts --- - -minetest.register_craft({ - type = "shapeless", - output = "lavastuff:ingot 9", - recipe = {"lavastuff:block"} -}) - -minetest.register_craft({ - output = "lavastuff:block", - recipe = { - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, - } -}) - --- --- Lava in a Bottle craft --- - -minetest.register_craft({ - output = "lavastuff:lava_in_a_bottle", - recipe = { - {"", "bucket:bucket_lava"}, - {"", "vessels:glass_bottle"}, - }, - replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}} -}) diff --git a/cooldowns.lua b/cooldowns.lua new file mode 100644 index 0000000..23424b2 --- /dev/null +++ b/cooldowns.lua @@ -0,0 +1,24 @@ +return { + players = {}, + set = function(self, player, time) + local pname = player:get_player_name() + + if self.players[pname] then + self.players[pname]:cancel() + + if not time then + self.players[pname] = nil + return + end + end + + if time > 0 then + self.players[pname] = minetest.after(time, function() self.players[pname] = nil end) + else + self.players[pname] = {cancel = function() end} + end + end, + get = function(self, player) + return self.players[player:get_player_name()] + end +} \ No newline at end of file diff --git a/crafts/mineclone.lua b/crafts/mineclone.lua new file mode 100644 index 0000000..3652242 --- /dev/null +++ b/crafts/mineclone.lua @@ -0,0 +1,95 @@ +-- +-- Ingot craft +-- + +minetest.register_craft({ + type = "shapeless", + output = "lavastuff:ingot 2", + recipe = {"mcl_mobitems:blaze_rod", "lavastuff:orb"} +}) + +-- +-- Orb craft +-- + +minetest.register_craft({ + output = "lavastuff:orb", + recipe = { + {"mcl_mobitems:blaze_powder", "mcl_mobitems:magma_cream", "mcl_mobitems:blaze_powder"}, + {"mcl_mobitems:magma_cream", "mcl_buckets:bucket_lava", "mcl_mobitems:magma_cream"}, + {"", "mcl_mobitems:magma_cream", ""} + }, + replacements = {{"mcl_buckets:bucket_lava", "mcl_buckets:bucket_empty"}} +}) + +-- +-- Tool crafts +-- + +minetest.register_craft({ + output = "lavastuff:sword", + recipe = { + {"lavastuff:ingot"}, + {"lavastuff:ingot"}, + {"mcl_core:iron_ingot"}, + } +}) + +minetest.register_craft({ + output = "lavastuff:pick", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"", "mcl_core:iron_ingot", ""}, + {"", "mcl_core:iron_ingot", ""}, + } +}) + +minetest.register_craft({ + output = "lavastuff:shovel", + recipe = { + {"lavastuff:ingot"}, + {"mcl_core:iron_ingot"}, + {"mcl_core:iron_ingot"}, + } +}) + +minetest.register_craft({ + output = "lavastuff:axe", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", ""}, + {"lavastuff:ingot", "mcl_core:iron_ingot", ""}, + {"", "mcl_core:iron_ingot", ""}, + } +}) + +-- +-- Block crafts +-- + +minetest.register_craft({ + type = "shapeless", + output = "lavastuff:ingot 9", + recipe = {"lavastuff:block"} +}) + +minetest.register_craft({ + output = "lavastuff:block", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + } +}) + +-- +-- Lava in a Bottle craft +-- + +minetest.register_craft({ + output = "lavastuff:lava_in_a_bottle", + recipe = { + {"", "mcl_buckets:bucket_lava"}, + {"", "mcl_potions:glass_bottle"}, + }, + replacements = {{"mcl_buckets:bucket_lava", "mcl_buckets:bucket_empty"}} +}) diff --git a/crafts/minetest_game.lua b/crafts/minetest_game.lua new file mode 100644 index 0000000..c76403c --- /dev/null +++ b/crafts/minetest_game.lua @@ -0,0 +1,98 @@ +-- Ingot craft +-- + +minetest.register_craft({ + type = "shapeless", + output = "lavastuff:ingot 2", + recipe = {"default:mese_crystal", "lavastuff:orb"} +}) + +-- +-- Orb craft +-- + +if not minetest.get_modpath("mobs_monster") and minetest.get_modpath("bucket") then + minetest.register_craft({ + output = "lavastuff:orb", + recipe = { + {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"}, + {"default:mese_crystal", "bucket:bucket_lava", "default:mese_crystal"}, + {"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"} + }, + replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}} + }) +end + +-- +-- Tool crafts +-- + +minetest.register_craft({ + output = "lavastuff:sword", + recipe = { + {"lavastuff:ingot"}, + {"lavastuff:ingot"}, + {"default:obsidian_shard"}, + } +}) + +minetest.register_craft({ + output = "lavastuff:pick", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"", "default:obsidian_shard", ""}, + {"", "default:obsidian_shard", ""}, + } +}) + +minetest.register_craft({ + output = "lavastuff:shovel", + recipe = { + {"lavastuff:ingot"}, + {"default:obsidian_shard"}, + {"default:obsidian_shard"}, + } +}) + +minetest.register_craft({ + output = "lavastuff:axe", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", ""}, + {"lavastuff:ingot", "default:obsidian_shard", ""}, + {"", "default:obsidian_shard", ""}, + } +}) + +-- +-- Block crafts +-- + +minetest.register_craft({ + type = "shapeless", + output = "lavastuff:ingot 9", + recipe = {"lavastuff:block"} +}) + +minetest.register_craft({ + output = "lavastuff:block", + recipe = { + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + {"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"}, + } +}) + +-- +-- Lava in a Bottle craft +-- + +if minetest.get_modpath("bucket") and minetest.get_modpath("vessels") then + minetest.register_craft({ + output = "lavastuff:lava_in_a_bottle", + recipe = { + {"", "bucket:bucket_lava"}, + {"", "vessels:glass_bottle"}, + }, + replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}} + }) +end \ No newline at end of file diff --git a/crafts/nodecore.lua b/crafts/nodecore.lua new file mode 100644 index 0000000..e69de29 diff --git a/init.lua b/init.lua index c7f6d91..d2b35b7 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,8 @@ lavastuff = {} +local MODPATH = minetest.get_modpath("lavastuff") + +local COOLDOWN = dofile(MODPATH.."/cooldowns.lua") local S if minetest.get_translator ~= nil then @@ -29,24 +32,43 @@ lavastuff.blacklisted_items = { -- Items lava tools will not smelt "default:mese", } -local fire_node - -if minetest.get_modpath("fire") then - fire_node = "fire:basic_flame" -elseif minetest.get_modpath("mcl_fire") then - fire_node = "mcl_fire:fire" -elseif minetest.get_modpath("nc_fire") then - fire_node = "nc_fire:fire" +if minetest.get_modpath("default") then + lavastuff.game = "minetest_game" +elseif minetest.get_modpath("mcl_core") then + lavastuff.game = "mineclone" +elseif minetest.get_modpath("nc_api") then + lavastuff.game = "nodecore" end -if minetest.registered_items[fire_node] and lavastuff.enable_tool_fire == true then +if minetest.get_modpath("fire") then + lavastuff.fire_node = "fire:basic_flame" +elseif minetest.get_modpath("mcl_fire") then + lavastuff.fire_node = "mcl_fire:fire" +elseif minetest.get_modpath("nc_fire") then + lavastuff.fire_node = "nc_fire:fire" +end + +if lavastuff.enable_tool_fire == true then + local function activate_func(user, pointedname, pointeddef, pointed) + if pointeddef.on_ignite then + pointeddef.on_ignite(pointed.under, user) + elseif lavastuff.fire_node and minetest.registered_nodes[lavastuff.fire_node] and + minetest.get_item_group(pointedname, "flammable") >= 1 and + minetest.get_node(pointed.above).name == "air" then + minetest.set_node(pointed.above, {name = lavastuff.fire_node}) + + if lavastuff.game == "nodecore" then + nodecore.fire_check_ignite(pointed.under) + end + end + end + function lavastuff.tool_fire_func(itemstack, user, pointed) local name = user:get_player_name() if pointed.type == "node" then local node = minetest.get_node(pointed.under) - local node_under = node.name - local def = minetest.registered_nodes[node_under] + local def = minetest.registered_nodes[node.name] if def.on_rightclick then return def.on_rightclick(pointed.under, node, user, itemstack, pointed) @@ -54,11 +76,10 @@ if minetest.registered_items[fire_node] and lavastuff.enable_tool_fire == true t if minetest.is_protected(pointed.under, name) then return end - if def.on_ignite then - def.on_ignite(pointed.under, user) - elseif minetest.get_item_group(node_under, "flammable") >= 1 - and minetest.get_node(pointed.above).name == "air" then - minetest.set_node(pointed.above, {name = fire_node}) + -- Only allow fire every 1+ second(s) + if not COOLDOWN:get(user) then + activate_func(user, node.name, def, pointed) + COOLDOWN:set(user, 1) end end end @@ -107,8 +128,9 @@ function lavastuff.burn_drops(tool) end end -lavastuff.burn_drops("lavastuff:sword") -lavastuff.burn_drops("lavastuff:axe") +lavastuff.burn_drops("lavastuff:sword" ) +lavastuff.burn_drops("lavastuff:pick" ) +lavastuff.burn_drops("lavastuff:axe" ) lavastuff.burn_drops("lavastuff:shovel") -- @@ -192,7 +214,7 @@ if minetest.get_modpath("3d_armor") or minetest.get_modpath("mcl_armor") then end -- --- Tools +--- Tools -- minetest.register_tool("lavastuff:sword", { @@ -216,57 +238,27 @@ minetest.register_tool("lavastuff:sword", { sound = {breaks = "default_tool_breaks"}, }) -if not minetest.get_modpath("mobs_monster") then - minetest.register_alias("mobs:pick_lava", "lavastuff:pick") - - minetest.register_tool("lavastuff:pick", { - description = S("Lava Pickaxe"), - inventory_image = "lavastuff_pick.png", - groups = {tool = 1, pickaxe = 1}, - light_source = 7, -- Texture will have a glow when dropped - tool_capabilities = { - burns = true, -- fire_plus support - full_punch_interval = 0.7, - max_drop_level = 3, - groupcaps={ - cracky = { - times = {[1] = 1.8, [2] = 0.8, [3] = 0.40}, - uses = 40, - maxlevel = 3 - }, +minetest.register_alias_force("mobs:pick_lava", "lavastuff:pick") +minetest.register_tool("lavastuff:pick", { + description = S("Lava Pickaxe"), + inventory_image = "lavastuff_pick.png", + groups = {tool = 1, pickaxe = 1}, + light_source = 7, -- Texture will have a glow when dropped + tool_capabilities = { + full_punch_interval = 0.7, + max_drop_level = 3, + groupcaps={ + cracky = { + times = {1.8, 0.8, 0.40}, + uses = 40, + maxlevel = 3 }, - damage_groups = {fleshy = 6, burns = 1}, }, - on_place = lavastuff.tool_fire_func, - }) - --- Lava Pick (restores autosmelt functionality) - - lavastuff.burn_drops("lavastuff:pick") -else - minetest.register_alias("lavastuff:pick", "mobs:pick_lava") - - minetest.register_tool(":mobs:pick_lava", { - description = S("Lava Pickaxe"), - inventory_image = "lavastuff_pick.png", - groups = {tool = 1, pickaxe = 1}, - light_source = 7, -- Texture will have a glow when dropped - tool_capabilities = { - burns = true, -- fire_plus support - full_punch_interval = 0.7, - max_drop_level = 3, - groupcaps={ - cracky = { - times = {[1] = 1.8, [2] = 0.8, [3] = 0.40}, - uses = 40, - maxlevel = 3 - }, - }, - damage_groups = {fleshy = 6, burns = 1}, - }, - on_place = lavastuff.tool_fire_func, - }) -end + damage_groups = {fleshy = 6, burns = 1}, + }, + on_place = lavastuff.tool_fire_func, + sound = {breaks = "default_tool_breaks"}, +}) minetest.register_tool("lavastuff:shovel", { description = S("Lava Shovel"), @@ -278,7 +270,11 @@ minetest.register_tool("lavastuff:shovel", { full_punch_interval = 1.0, max_drop_level=1, groupcaps={ - crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30}, uses=30, maxlevel=3}, + crumbly = { + times = {[1]=1.10, [2]=0.50, [3]=0.30}, + uses = 30, + maxlevel = 3 + }, }, damage_groups = {fleshy=4}, }, @@ -296,7 +292,7 @@ minetest.register_tool("lavastuff:axe", { max_drop_level = 1, groupcaps = { choppy = { - times = {[1] = 2.00, [2] = 0.80, [3] = 0.40}, + times = {2.00, 0.80, 0.40}, uses = 40, maxlevel = 3 }, @@ -321,6 +317,72 @@ if minetest.get_modpath("mobs_monster") then }) end +-- +-- Armor +-- + +if minetest.get_modpath("3d_armor") then + armor.materials.lava = "lavastuff:ingot" + armor.config.material_lava = true + + armor:register_armor("lavastuff:helmet_lava", { + description = S("Lava Helmet"), + inventory_image = "lavastuff_inv_helmet.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_head=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=15}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + minetest.register_alias("lavastuff:helmet", "lavastuff:helmet_lava") + + armor:register_armor("lavastuff:chestplate_lava", { + description = S("Lava Chestplate"), + inventory_image = "lavastuff_inv_chestplate.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_torso=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=20}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + minetest.register_alias("lavastuff:chestplate", "lavastuff:chestplate_lava") + + armor:register_armor("lavastuff:leggings_lava", { + description = S("Lava Leggings"), + inventory_image = "lavastuff_inv_leggings.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_legs=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=20}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + minetest.register_alias("lavastuff:leggings", "lavastuff:leggings_lava") + + armor:register_armor("lavastuff:boots_lava", { + description = S("Lava Boots"), + inventory_image = "lavastuff_inv_boots.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_feet=1, armor_heal=12, armor_use=100, armor_fire=10, physics_jump=0.5, physics_speed = 1}, + armor_groups = {fleshy=15}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + minetest.register_alias("lavastuff:boots", "lavastuff:boots_lava") + + if minetest.get_modpath("shields") then + armor:register_armor("lavastuff:shield_lava", { + description = S("Lava Shield"), + inventory_image = "lavastuff_inven_shield.png", + light_source = 7, -- Texture will have a glow when dropped + groups = {armor_shield=1, armor_heal=12, armor_use=100, armor_fire=10}, + armor_groups = {fleshy=20}, + damage_groups = {cracky=2, snappy=1, level=3}, + wear = 0, + }) + minetest.register_alias("lavastuff:shield", "lavastuff:shield_lava") + end +end + -- -- Nodes -- @@ -418,11 +480,17 @@ minetest.register_node("lavastuff:lava_in_a_bottle", { }) -- --- Register crafts based on current game +-- Register crafts/tools based on current game -- -if minetest.get_modpath("default") and minetest.get_modpath("bucket") and minetest.get_modpath("vessels") then - dofile(minetest.get_modpath("lavastuff") .. "/compat/mtg.lua") -elseif minetest.get_modpath("mcl_core") then - dofile(minetest.get_modpath("lavastuff") .. "/compat/mcl2.lua") +if lavastuff.game == "nodecore" then + dofile(MODPATH .. "/crafts/nodecore.lua") + dofile(MODPATH.."/items/nodecore.lua")(COOLDOWN, S) +elseif lavastuff.game == "mineclone" then + dofile(MODPATH.."/items/mineclone.lua")(COOLDOWN, S) + dofile(MODPATH .. "/crafts/mineclone.lua") +else + if lavastuff.game == "minetest_game" then + dofile(MODPATH .. "/crafts/minetest_game.lua") + end end diff --git a/items/mineclone.lua b/items/mineclone.lua new file mode 100644 index 0000000..d198021 --- /dev/null +++ b/items/mineclone.lua @@ -0,0 +1,65 @@ +return function(cooldown, S) + +for _, item in pairs({"lavastuff:sword", "lavastuff:pick", "lavastuff:axe", "lavastuff:shovel"}) do + local itype = item:sub(item:find(":")+1) + local mcldef = table.copy(minetest.registered_items[("mcl_tools:%s_diamond"):format(itype)]) + + mcldef.tool_capabilities.damage_groups.fleshy = mcldef.tool_capabilities.damage_groups.fleshy + 1 + mcldef.tool_capabilities.full_punch_interval = mcldef.tool_capabilities.full_punch_interval - 0.1 + + minetest.override_item(item, { + tool_capabilities = mcldef.tool_capabilities, + groups = mcldef.groups, + wield_scale = mcldef.wield_scale, + sound = mcldef.sound, + _repair_material = "lavastuff:ingot", + _mcl_toollike_wield = true, + _doc_items_longdesc = mcldef._doc_items_longdesc, + }) +end + +minetest.override_item("lavastuff:block", { + stack_max = 64, + groups = {pickaxey=3, building_block=1}, + sounds = mcl_sounds.node_sound_stone_defaults(), + _mcl_blast_resistance = 6, + _mcl_hardness = 4, +}) + +for _, item in pairs({"lavastuff:ingot", "lavastuff:orb"}) do + minetest.override_item(item, { + stack_max = 64, + }) +end + +for item, desc in pairs({ + ["lavastuff:helmet" ] = "Lava Helmet" , + ["lavastuff:chestplate"] = "Lava Chestplate", + ["lavastuff:leggings" ] = "Lava Leggings" , + ["lavastuff:boots" ] = "Lava Boots" , +}) do + local itype = item:match(":(.+)") + minetest.log(dump(("mcl_armor:%s_diamond"):format(itype))) + local mcldef = table.copy(minetest.registered_items[("mcl_armor:%s_diamond"):format(itype)]) + + mcldef.groups.mcl_armor_uses = mcldef.groups.mcl_armor_uses * 2 + mcldef.groups.armor_fire = 10 + mcldef.groups.physics_jump = 0.5 + mcldef.groups.physics_speed = 1 + + minetest.register_tool(item, { + description = S(desc), + texture = ("lavastuff_%s_lava"):format(itype), + _doc_items_longdesc = mcldef._doc_items_longdesc, + _doc_items_usagehelp = mcldef._doc_items_longdesc, + inventory_image = "lavastuff_inv_"..itype..".png", + light_source = 7, -- Texture will have a glow when dropped + groups = mcldef.groups, + _repair_material = "lavastuff:ingot", + sounds = mcldef.sounds, + on_place = mcldef.on_place, + on_secondary_use = mcldef.on_place, + }) +end + +end \ No newline at end of file diff --git a/items/nodecore.lua b/items/nodecore.lua new file mode 100644 index 0000000..b4900c4 --- /dev/null +++ b/items/nodecore.lua @@ -0,0 +1,96 @@ +return function(cooldown, S) + +local function finish(self) + local pos = self.object:get_pos() + + if pos then + minetest.after(0.1, function() + if minetest.get_node(pos).name == "air" then + minetest.set_node(pos, {name = "nc_optics:glass_hot_source"}) + end + end) + end + self.object:remove() +end + +minetest.register_entity("lavastuff:shoveling_glass", { + is_visible = true, + visual = "wielditem", + textures = {"nc_optics:glass_hot_source"}, + visual_size = vector.new(0.66, 0.66, 0.66), -- scale to just under regular node size + collisionbox = {-0.48, -0.48, -0.48, 0.48, 0.48, 0.48}, + physical = true, + collide_with_objects = false, + makes_footstep_sound = false, + backface_culling = true, + static_save = true, + pointable = false, + glow = minetest.LIGHT_MAX, + on_punch = function() return true end, + on_step = function(self, dtime) + if not self.player then return finish(self) end + + local player = minetest.get_player_by_name(self.player) + if not player then return finish(self) end + + if player:get_player_control().dig or player:get_wielded_item():get_name() ~= "lavastuff:shovel" then + cooldown:set(player) -- remove cooldown that was set when the glass was picked up + return finish(self) + end + + local phead = vector.add(player:get_pos(), {x=0,z=0, y = player:get_properties().eye_height or 0}) + local targpos = vector.round(vector.add(phead, vector.multiply(player:get_look_dir(), 4))) + local objpos = self.object:get_pos() + + local objtargpos = minetest.raycast(phead, targpos, false, true) + local next = objtargpos:next() + + objtargpos = (next and next.type == "node" and next.above) or targpos + + local dist = vector.distance(objpos, objtargpos) + + if dist >= 0.4 then + self.object:set_velocity(vector.multiply(vector.direction(objpos, objtargpos), dist * 5)) + elseif vector.length(self.object:get_velocity()) ~= 0 then + self.object:set_velocity(vector.new(0, 0, 0)) + self.object:set_pos(objtargpos) + end + end, +}) + +minetest.override_item("lavastuff:sword", { + sound = {breaks = "nc_api_toolbreak"}, +}) + +minetest.override_item("lavastuff:pick", { + tool_capabilities = minetest.registered_tools["nc_lux:tool_pick_tempered"].tool_capabilities, + sound = {breaks = "nc_api_toolbreak"}, +}) + +minetest.override_item("lavastuff:shovel", { + tool_capabilities = minetest.registered_tools["nc_lux:tool_spade_tempered"].tool_capabilities, + on_place = function(itemstack, user, pointed_thing, ...) + if not pointed_thing or pointed_thing.type ~= "node" then return end + + local node = minetest.get_node(pointed_thing.under) + local def = minetest.registered_nodes[node.name] + + if not cooldown:get(user) and (def.groups.sand or (def.groups.silica_molten and def.liquidtype == "source")) then + cooldown:set(user, 0) + minetest.remove_node(pointed_thing.under) + local ent = minetest.add_entity(pointed_thing.under, "lavastuff:shoveling_glass") + ent:get_luaentity().player = user:get_player_name() + else + return lavastuff.tool_fire_func(itemstack, user, pointed_thing, ...) + end + end, + sound = {breaks = "nc_api_toolbreak"}, +}) + +minetest.override_item("lavastuff:axe", { + tool_capabilities = minetest.registered_tools["nc_lux:tool_hatchet_tempered"].tool_capabilities, + on_place = lavastuff.tool_fire_func, + sound = {breaks = "nc_api_toolbreak"}, +}) + +end \ No newline at end of file diff --git a/mod.conf b/mod.conf index e0e1d81..5a96b31 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,9 @@ name = lavastuff description = Adds lava tools, armor, and blocks title = Lava Stuff -optional_depends = fire, stairs, mobs_monster, 3d_armor, toolranks, moreblocks, vessels, default, bucket, mcl_armor, mcl_fire, mcl_buckets, mcl_nether, mcl_potions, mcl_core, mcl_mobitems, mcl_tools, nc_fire +optional_depends = """ + mobs_monster, 3d_armor, toolranks, moreblocks, + fire, stairs, vessels, default, bucket, + mcl_armor, mcl_fire, mcl_buckets, mcl_nether, mcl_potions, mcl_core, mcl_mobitems, mcl_tools, + nc_fire, nc_api_all, nc_lux, nc_optics +""" diff --git a/readme.md b/readme.md index 466ac87..d9073a8 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,11 @@ # Lavastuff [![](https://github.com/minetest-mods/lavastuff/workflows/Check%20&%20Release/badge.svg)](https://github.com/minetest-mods/lavastuff/actions) +[![ContentDB](https://content.minetest.net/packages/Lone_Wolf/lavastuff/shields/downloads/)](https://content.minetest.net/packages/Lone_Wolf/lavastuff/) -Adds lava armor, tools, and blocks +Adds lava armor (where possible), tools, and blocks + +Please tell me (and everyone else) what you think at https://content.minetest.net/packages/Lone_Wolf/lavastuff/review/ ## **API** @@ -14,7 +17,8 @@ Adds lava armor, tools, and blocks ## **Game support** * **Minetest Game** - 100% support -* **MineClone2** - (Some features are lost) +* **MineClone2** - (Partial support) +* **NodeCore** - (Coming soon, /give works) ## **Language support**