ExchangeClone/exchangeclone/hammers.lua

189 lines
6.7 KiB
Lua
Raw Normal View History

2023-11-19 01:48:35 +01:00
local S = minetest.get_translator()
local stone_group = "cracky"
2023-09-29 01:23:49 +02:00
if exchangeclone.mcl then
stone_group = "pickaxey"
end
2023-08-07 22:56:29 +02:00
exchangeclone.hammer_action = {
2023-11-19 01:48:35 +01:00
start_action = function(player, center, range, itemstack)
2023-08-07 22:56:29 +02:00
if exchangeclone.check_cooldown(player, "hammer") then return end
local data = {}
exchangeclone.multidig[player:get_player_name()] = true -- to prevent doing 3x3 as well as AOE
exchangeclone.play_ability_sound(player)
2023-11-19 01:48:35 +01:00
data.itemstack = itemstack
2023-08-07 22:56:29 +02:00
return data
end,
action = function(player, pos, node, data)
if minetest.get_item_group(node.name, stone_group) ~= 0 then
if minetest.is_protected(pos, player:get_player_name()) then
minetest.record_protection_violation(pos, player:get_player_name())
else
2023-11-19 01:48:35 +01:00
local drops = minetest.get_node_drops(node.name, data.itemstack)
2023-08-07 22:56:29 +02:00
exchangeclone.drop_items_on_player(pos, drops, player)
minetest.set_node(pos, {name = "air"})
end
end
return data
end,
end_action = function(player, center, range, data)
exchangeclone.multidig[player:get_player_name()] = nil
exchangeclone.start_cooldown(player, "hammer", range/2) -- The hammer has by far the most lag potential and therefore a long cooldown.
end
}
local function hammer_on_place(itemstack, player, pointed_thing)
local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing)
if click_test ~= false then
return click_test
end
if player:get_player_control().aux1 then
if itemstack:get_name():find("dark") then
return exchangeclone.range_update(itemstack, player, 3)
else
return exchangeclone.range_update(itemstack, player, 4)
end
end
if player:get_player_control().sneak then
local current_name = itemstack:get_name()
if string.sub(current_name, -4, -1) == "_3x3" then
itemstack:set_name(string.sub(current_name, 1, -5))
2023-11-19 01:48:35 +01:00
minetest.chat_send_player(player:get_player_name(), S("Single node mode"))
else
itemstack:set_name(current_name.."_3x3")
2023-11-19 01:48:35 +01:00
minetest.chat_send_player(player:get_player_name(), S("3x3 mode"))
end
return itemstack
end
local range = itemstack:get_meta():get_int("exchangeclone_item_range")
local center = player:get_pos()
if pointed_thing.type == "node" then
center = pointed_thing.under
end
2023-11-19 01:48:35 +01:00
exchangeclone.node_radius_action(player, center, range, exchangeclone.hammer_action, itemstack)
end
minetest.register_tool("exchangeclone:dark_matter_hammer", {
2023-11-19 01:48:35 +01:00
description = S("Dark Matter Hammer").."\n"..S("Single node mode"),
wield_image = "exchangeclone_dark_matter_hammer.png",
inventory_image = "exchangeclone_dark_matter_hammer.png",
2023-10-07 17:26:21 +02:00
groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, dark_matter_hammer = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
wield_scale = exchangeclone.wield_scale,
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.5,
2023-10-30 23:42:11 +01:00
max_drop_level=6,
damage_groups = {fleshy=7},
punch_attack_uses = 0,
groupcaps={
cracky = {times={[1]=1.5, [2]=0.75, [3]=0.325}, uses=0, maxlevel=4},
},
},
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { speed = 16, level = 7, uses = 0 }
},
on_place = hammer_on_place,
on_secondary_use = hammer_on_place,
})
minetest.register_tool("exchangeclone:dark_matter_hammer_3x3", {
2023-11-19 01:48:35 +01:00
description = S("Dark Matter Hammer").."\n"..S("3x3 mode"),
wield_image = "exchangeclone_dark_matter_hammer.png",
inventory_image = "exchangeclone_dark_matter_hammer.png",
2023-10-07 17:26:21 +02:00
groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, dark_matter_hammer = 1, not_in_creative_inventory = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
wield_scale = exchangeclone.wield_scale,
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.5,
2023-10-30 23:42:11 +01:00
max_drop_level=6,
damage_groups = {fleshy=7},
punch_attack_uses = 0,
groupcaps={
cracky = {times={[1]=1.8, [2]=0.9, [3]=0.5}, uses=0, maxlevel=4},
},
},
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { speed = 12, level = 7, uses = 0 }
},
on_place = hammer_on_place,
on_secondary_use = hammer_on_place,
})
2023-11-19 01:48:35 +01:00
exchangeclone.register_energy_alias("exchangeclone:dark_matter_hammer", "exchangeclone:dark_matter_hammer_3x3")
minetest.register_tool("exchangeclone:red_matter_hammer", {
2023-11-19 01:48:35 +01:00
description = S("Red Matter Hammer").."\n"..S("Single node mode"),
wield_image = "exchangeclone_red_matter_hammer.png",
inventory_image = "exchangeclone_red_matter_hammer.png",
2023-10-07 17:26:21 +02:00
groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, red_matter_hammer = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
wield_scale = exchangeclone.wield_scale,
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.3,
2023-10-30 23:42:11 +01:00
max_drop_level=7,
damage_groups = {fleshy=9},
punch_attack_uses = 0,
groupcaps={
cracky = {times={[1]=1, [2]=0.5, [3]=0.2}, uses=0, maxlevel=5},
},
},
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { speed = 19, level = 8, uses = 0 }
},
on_place = hammer_on_place,
on_secondary_use = hammer_on_place,
})
minetest.register_tool("exchangeclone:red_matter_hammer_3x3", {
2023-11-19 01:48:35 +01:00
description = S("Red Matter Hammer\n3x3 mode"),
wield_image = "exchangeclone_red_matter_hammer.png",
inventory_image = "exchangeclone_red_matter_hammer.png",
2023-10-07 17:26:21 +02:00
groups = { tool=1, hammer=1, dig_speed_class=7, enchantability=0, red_matter_hammer = 1, not_in_creative_inventory = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
wield_scale = exchangeclone.wield_scale,
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.3,
2023-10-30 23:42:11 +01:00
max_drop_level=7,
damage_groups = {fleshy=9},
punch_attack_uses = 0,
groupcaps={
cracky = {times={[1]=1.25, [2]=0.6, [3]=0.3}, uses=0, maxlevel=5},
},
},
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { speed = 14, level = 8, uses = 0 }
},
on_place = hammer_on_place,
on_secondary_use = hammer_on_place,
})
2023-11-19 01:48:35 +01:00
exchangeclone.register_energy_alias("exchangeclone:red_matter_hammer", "exchangeclone:red_matter_hammer_3x3")
minetest.register_craft({
output = "exchangeclone:dark_matter_hammer",
recipe = {
2023-11-10 03:35:23 +01:00
{"exchangeclone:dark_matter", exchangeclone.itemstrings.diamond, "exchangeclone:dark_matter"},
{"", exchangeclone.itemstrings.diamond, ""},
{"", exchangeclone.itemstrings.diamond, ""}
}
})
minetest.register_craft({
output = "exchangeclone:red_matter_hammer",
recipe = {
{"exchangeclone:red_matter", "exchangeclone:dark_matter", "exchangeclone:red_matter"},
{"", "group:dark_matter_hammer", ""},
{"", "exchangeclone:dark_matter", ""}
}
})