ExchangeClone/exchangeclone/shovels.lua

139 lines
4.8 KiB
Lua
Raw Normal View History

2023-08-07 22:56:29 +02:00
exchangeclone.shovel_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, "shovel") then return end
local data = {}
2023-09-29 01:23:49 +02:00
if exchangeclone.mcl then
2023-08-07 22:56:29 +02:00
data.path = not player:get_player_control().sneak
2023-06-23 23:02:22 +02:00
end
2023-08-07 22:56:29 +02:00
if range > 0 or not data.path then
exchangeclone.play_ability_sound(player)
2023-06-23 23:02:22 +02:00
end
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)
2023-06-23 23:02:22 +02:00
if ((minetest.get_item_group(node.name, "crumbly") > 0) or (minetest.get_item_group(node.name, "shovely") > 0)) then
2023-08-07 22:56:29 +02:00
if minetest.is_protected(pos, player:get_player_name()) then
minetest.record_protection_violation(pos, player:get_player_name())
2023-06-23 23:02:22 +02:00
else
2023-08-07 22:56:29 +02:00
if data.path then
2023-09-29 01:23:49 +02:00
-- TODO: Fix potential "shovel_on_place" functions that aren't paths in Mineclonia
if minetest.registered_items[node.name]._on_shovel_place or
minetest.get_item_group(node.name, "path_creation_possible") == 1 then
if minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name == "air" then
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pos}, true)
minetest.swap_node(pos, {name="mcl_core:grass_path"})
end
2023-06-23 23:02:22 +02:00
end
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"})
2023-06-23 23:02:22 +02:00
end
end
end
2023-08-07 22:56:29 +02:00
return data
end,
end_action = function(player, center, range, data)
if range > 0 or not data.path then
exchangeclone.start_cooldown(player, "shovel", range/4) -- Longish cooldown
end
2023-06-23 23:02:22 +02:00
end
2023-08-07 22:56:29 +02:00
}
2023-06-23 23:02:22 +02:00
local function shovel_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
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.shovel_action, itemstack)
2023-06-23 23:02:22 +02:00
return itemstack
end
minetest.register_tool("exchangeclone:dark_matter_shovel", {
description = "Dark Matter Shovel",
wield_image = "exchangeclone_dark_matter_shovel.png",
inventory_image = "exchangeclone_dark_matter_shovel.png",
2023-10-30 23:42:11 +01:00
groups = { tool=1, shovel=1, dig_speed_class=6, enchantability=0, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
2023-06-23 23:02:22 +02:00
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,
2023-06-23 23:02:22 +02:00
damage_groups = {fleshy=7},
punch_attack_uses = 0,
groupcaps={
crumbly = {times={[1]=0.9, [2]=0.45, [3]=0.225}, uses=0, maxlevel=4},
},
},
sound = { breaks = "default_tool_breaks" },
on_place = shovel_on_place,
on_secondary_use = shovel_on_place,
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { speed = 16, level = 7, uses = 0 }
},
})
minetest.register_tool("exchangeclone:red_matter_shovel", {
description = "Red Matter Shovel",
wield_image = "exchangeclone_red_matter_shovel.png",
inventory_image = "exchangeclone_red_matter_shovel.png",
2023-10-30 23:42:11 +01:00
groups = { tool=1, shovel=1, dig_speed_class=7, enchantability=0, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
2023-06-23 23:02:22 +02:00
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=7,
2023-06-23 23:02:22 +02:00
damage_groups = {fleshy=9},
punch_attack_uses = 0,
groupcaps={
crumbly = {times={[1]=0.6, [2]=0.25, [3]=0.1}, uses=0, maxlevel=5},
},
},
sound = { breaks = "default_tool_breaks" },
on_place = shovel_on_place,
on_secondary_use = shovel_on_place,
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { speed = 19, level = 8, uses = 0 }
},
})
--Crafting recipes
minetest.register_craft({
output = "exchangeclone:dark_matter_shovel",
recipe = {
{"exchangeclone:dark_matter"},
2023-11-10 03:35:23 +01:00
{exchangeclone.itemstrings.diamond},
{exchangeclone.itemstrings.diamond}
2023-06-23 23:02:22 +02:00
}
})
minetest.register_craft({
output = "exchangeclone:red_matter_shovel",
recipe = {
{"exchangeclone:red_matter"},
{"exchangeclone:dark_matter_shovel"},
{"exchangeclone:dark_matter"}
}
})