adding jewels

This commit is contained in:
kaadmy 2015-09-01 19:11:29 -07:00
parent e35d8805a4
commit 3a3e202207
7 changed files with 118 additions and 1 deletions

View File

@ -30,7 +30,7 @@ if minetest.setting_getbool("creative_mode") == true then
{ {
type = "none", type = "none",
wield_image = "wieldhand.png", wield_image = "wieldhand.png",
wield_scale = {x=1,y=1,z=2.0}, wield_scale = {x=1.5,y=3,z=3},
tool_capabilities = { tool_capabilities = {
full_punch_interval = 1.0, full_punch_interval = 1.0,
max_drop_level = 0, max_drop_level = 0,

8
mods/jewels/README.txt Normal file
View File

@ -0,0 +1,8 @@
Jewels mod
==========
By Kaadmy
Adds tools with different stats via a Jeweler's Workbench.
Asset license: WTFPL
Source license: WTFPL

1
mods/jewels/depends.txt Normal file
View File

@ -0,0 +1 @@
default

108
mods/jewels/init.lua Normal file
View File

@ -0,0 +1,108 @@
--
-- Jewels mod
-- By Kaadmy
--
jewels = {}
jewels.registered_jewels = {}
local function p(i)
if i >= 0 then i = "+" .. i end
return i
end
function jewels.register_jewel(toolname, new_toolname, def)
-- registers a new tool with different stats
local data = {
overlay = def.overlay or "jewels_jeweled_handle.png", -- overlay image
stats = {
digspeed = def.stats.digspeed, -- negative digs faster
maxlevel = def.stats.maxlevel, -- positive digs higher levels
maxdrop= def.stats.maxdrop, -- positive increases max drop level
uses = def.stats.uses, -- positive increases uses
fleshy = def.stats.fleshy, -- positive increases fleshy damage
range = def.stats.range, -- positive increases reach distance with tool
}
}
jewels.registered_jewels[toolname] = data
local tooldef = minetest.registered_tools[toolname]
local new_tool_invimage = ""
if tooldef.inventory_image then
new_tool_invimage = tooldef.inventory_image .. "^" .. data.overlay
end
local new_tool_wieldimage = ""
if tooldef.wield_image then
new_tool_wieldimage = tooldef.wield_image .. "^" .. data.overlay
end
local new_tooldef = tooldef
local desc = new_tooldef.description or ""
desc = "Jeweled " .. desc
new_tooldef.inventory_image = new_tool_invimage
new_tooldef.wield_image = new_tool_wieldimage
if data.stats.range and new_tooldef.range then
new_tooldef.range = new_tooldef.range + data.stats.range
desc = desc .. "\nRange: " .. p(data.stats.range)
end
if new_tooldef.tool_capabilities then
if data.stats.maxdrop and new_tooldef.tool_capabilities.max_drop_level then
new_tooldef.tool_capabilities.max_drop_level = new_tooldef.tool_capabilities.max_drop_level + data.stats.maxdrop
desc = desc .. "\nDrop level: " .. p(data.stats.maxdrop)
end
if data.stats.digspeed then
for group, cap in pairs(new_tooldef.tool_capabilities.groupcaps) do
for i, _ in ipairs(cap.times) do
cap.times[i] = cap.times[i] + data.stats.digspeed
end
if data.stats.maxlevel and cap.maxlevel then
cap.maxlevel = cap.maxlevel + data.stats.maxlevel
desc = desc .. "\nDig level: " .. p(data.stats.maxlevel)
end
if data.stats.uses and cap.uses then
cap.uses = cap.uses + data.stats.uses
desc = desc .. "\nUses: " .. p(data.stats.uses)
end
end
desc = desc .. "\nDig speed: " .. p(data.stats.digspeed) .. " seconds"
end
if data.stats.fleshy and new_tooldef.tool_capabilities.damage_groups and new_tooldef.tool_capabilities.damage_groups.fleshy then
new_tooldef.tool_capabilities.damage_groups.fleshy = new_tooldef.tool_capabilities.damage_groups.fleshy + data.stats.fleshy
desc = desc .. "\nDamage: " .. p(data.stats.fleshy)
end
end
new_tooldef.description = desc
minetest.register_tool(new_toolname, new_tooldef)
end
jewels.register_jewel(
"default:pick_steel",
"jewels:pick_steel_digspeed",
{
stats = {
fleshy = 2,
}
})
minetest.register_craftitem(
"jewels:jewel",
{
description = "Jewel",
inventory_image = "jewels_jewel.png",
stack_max = 10
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

Binary file not shown.