generated from jasonl8446/minetest-boilerplate
Added sharpness
This commit is contained in:
parent
d6973c26ed
commit
9c70dc9c09
26
enchants.lua
26
enchants.lua
@ -1,9 +1,6 @@
|
|||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
local S = minetest.get_translator(modname)
|
local S = minetest.get_translator(modname)
|
||||||
-- TODO:
|
|
||||||
-- Make sure enchantment is an enchantment
|
|
||||||
-- Make sure level is a number
|
|
||||||
-- Make sure enchantment is possible (correct tool)
|
|
||||||
function tool_level_enchanting.set_enchantment(itemstack,enchantment_name,level)
|
function tool_level_enchanting.set_enchantment(itemstack,enchantment_name,level)
|
||||||
local itemmeta = itemstack:get_meta()
|
local itemmeta = itemstack:get_meta()
|
||||||
local itemdef = itemstack:get_definition()
|
local itemdef = itemstack:get_definition()
|
||||||
@ -14,6 +11,9 @@ function tool_level_enchanting.set_enchantment(itemstack,enchantment_name,level)
|
|||||||
if enchantment_name == "efficiency" then
|
if enchantment_name == "efficiency" then
|
||||||
itemstack = tool_level_enchanting.efficiency_change(itemstack,level)
|
itemstack = tool_level_enchanting.efficiency_change(itemstack,level)
|
||||||
end
|
end
|
||||||
|
if enchantment_name == "sharpness" then
|
||||||
|
itemstack = tool_level_enchanting.sharpness_change(itemstack,level)
|
||||||
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -36,7 +36,6 @@ end
|
|||||||
function tool_level_enchanting.efficiency_change(itemstack, enchant_level)
|
function tool_level_enchanting.efficiency_change(itemstack, enchant_level)
|
||||||
local itemmeta = itemstack:get_meta()
|
local itemmeta = itemstack:get_meta()
|
||||||
local itemdef = itemstack:get_definition()
|
local itemdef = itemstack:get_definition()
|
||||||
print(ItemStack("default:pick_diamond"):get_tool_capabilities())
|
|
||||||
if itemdef.tool_capabilities then
|
if itemdef.tool_capabilities then
|
||||||
local speed_multiplier = 1 - (0.1 * tonumber(enchant_level))
|
local speed_multiplier = 1 - (0.1 * tonumber(enchant_level))
|
||||||
local cap = table.copy(itemdef.tool_capabilities)
|
local cap = table.copy(itemdef.tool_capabilities)
|
||||||
@ -136,12 +135,23 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- Sharpness?
|
-- Sharpness?
|
||||||
-- 10% per level? idk
|
-- 10% per level?
|
||||||
-- max level 10
|
-- max level 5
|
||||||
|
function tool_level_enchanting.sharpness_change(itemstack, enchant_level)
|
||||||
|
local itemmeta = itemstack:get_meta()
|
||||||
|
local itemdef = itemstack:get_definition()
|
||||||
|
if itemdef.tool_capabilities.damage_groups.fleshy then
|
||||||
|
local damage_multiplier = 1 - (0.1 * tonumber(enchant_level))
|
||||||
|
local cap = table.copy(itemdef.tool_capabilities)
|
||||||
|
cap.damage_groups.fleshy = cap.damage_groups.fleshy * damage_multiplier
|
||||||
|
itemmeta:set_tool_capabilities(cap)
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
-- TODO:
|
-- TODO:
|
||||||
-- Make sure enchantment is an enchantment
|
-- Make sure enchantment is an enchantment
|
||||||
-- Make sure level is a number
|
-- Make sure level is a number
|
||||||
|
-- Make sure enchantment on tool is possible
|
||||||
minetest.register_chatcommand("enchant", {
|
minetest.register_chatcommand("enchant", {
|
||||||
description = S("Enchant an item"),
|
description = S("Enchant an item"),
|
||||||
params = S("<player> <enchantment> [<level>]"),
|
params = S("<player> <enchantment> [<level>]"),
|
||||||
|
17
init.lua
17
init.lua
@ -1,8 +1,10 @@
|
|||||||
local path = minetest.get_modpath('tool_level_enchanting')
|
local path = minetest.get_modpath('tool_level_enchanting')
|
||||||
local S = minetest.get_translator("tool_level_enchanting")
|
local S = minetest.get_translator("tool_level_enchanting")
|
||||||
|
|
||||||
tool_level_enchanting = {
|
tool_level_enchanting = {}
|
||||||
registered_ores = {
|
|
||||||
|
-- List of ores that work with fortune
|
||||||
|
tool_level_enchanting.registered_ores = {
|
||||||
['default:stone_with_coal'] = true,
|
['default:stone_with_coal'] = true,
|
||||||
['default:stone_with_copper'] = true,
|
['default:stone_with_copper'] = true,
|
||||||
['default:stone_with_diamond'] = true,
|
['default:stone_with_diamond'] = true,
|
||||||
@ -10,7 +12,16 @@ tool_level_enchanting = {
|
|||||||
['default:stone_with_iron'] = true,
|
['default:stone_with_iron'] = true,
|
||||||
['default:stone_with_mese'] = true,
|
['default:stone_with_mese'] = true,
|
||||||
['default:stone_with_tin'] = true,
|
['default:stone_with_tin'] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- List of enchantments and max levels
|
||||||
|
tool_level_enchanting.registered_enchantments = {
|
||||||
|
['unbreaking'] = 10,
|
||||||
|
['efficiency'] = 5,
|
||||||
|
['silk_touch'] = 10,
|
||||||
|
['fortune'] = 10,
|
||||||
|
['auto_repair'] = 10,
|
||||||
|
['sharpness'] = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
dofile(path .. '/enchants.lua')
|
dofile(path .. '/enchants.lua')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user