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 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)
|
||||
local itemmeta = itemstack:get_meta()
|
||||
local itemdef = itemstack:get_definition()
|
||||
@ -14,6 +11,9 @@ function tool_level_enchanting.set_enchantment(itemstack,enchantment_name,level)
|
||||
if enchantment_name == "efficiency" then
|
||||
itemstack = tool_level_enchanting.efficiency_change(itemstack,level)
|
||||
end
|
||||
if enchantment_name == "sharpness" then
|
||||
itemstack = tool_level_enchanting.sharpness_change(itemstack,level)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
@ -36,7 +36,6 @@ end
|
||||
function tool_level_enchanting.efficiency_change(itemstack, enchant_level)
|
||||
local itemmeta = itemstack:get_meta()
|
||||
local itemdef = itemstack:get_definition()
|
||||
print(ItemStack("default:pick_diamond"):get_tool_capabilities())
|
||||
if itemdef.tool_capabilities then
|
||||
local speed_multiplier = 1 - (0.1 * tonumber(enchant_level))
|
||||
local cap = table.copy(itemdef.tool_capabilities)
|
||||
@ -136,12 +135,23 @@ minetest.register_globalstep(function(dtime)
|
||||
end)
|
||||
|
||||
-- Sharpness?
|
||||
-- 10% per level? idk
|
||||
-- max level 10
|
||||
|
||||
-- 10% per level?
|
||||
-- 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:
|
||||
-- Make sure enchantment is an enchantment
|
||||
-- Make sure level is a number
|
||||
-- Make sure enchantment on tool is possible
|
||||
minetest.register_chatcommand("enchant", {
|
||||
description = S("Enchant an item"),
|
||||
params = S("<player> <enchantment> [<level>]"),
|
||||
|
31
init.lua
31
init.lua
@ -1,16 +1,27 @@
|
||||
local path = minetest.get_modpath('tool_level_enchanting')
|
||||
local S = minetest.get_translator("tool_level_enchanting")
|
||||
|
||||
tool_level_enchanting = {
|
||||
registered_ores = {
|
||||
['default:stone_with_coal'] = true,
|
||||
['default:stone_with_copper'] = true,
|
||||
['default:stone_with_diamond'] = true,
|
||||
['default:stone_with_gold'] = true,
|
||||
['default:stone_with_iron'] = true,
|
||||
['default:stone_with_mese'] = true,
|
||||
['default:stone_with_tin'] = true,
|
||||
}
|
||||
tool_level_enchanting = {}
|
||||
|
||||
-- List of ores that work with fortune
|
||||
tool_level_enchanting.registered_ores = {
|
||||
['default:stone_with_coal'] = true,
|
||||
['default:stone_with_copper'] = true,
|
||||
['default:stone_with_diamond'] = true,
|
||||
['default:stone_with_gold'] = true,
|
||||
['default:stone_with_iron'] = true,
|
||||
['default:stone_with_mese'] = 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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user