Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions metal_melter/caster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ metal_caster.max_metal = 16000
-- Use melter values
metal_caster.spec = metal_melter.spec

local ingot_cast_image = fluidity.external.is_mcl
and "metal_melter_ingot_cast_mcl.png"
or "metal_melter_ingot_cast.png"

metal_caster.casts = {
ingot = {description = S("Ingot"), result = "ingot", cost = 1, typenames = {"ingot"}},
ingot = {
description = S("Ingot"),
inventory_image = ingot_cast_image,
result = "ingot",
cost = 1,
typenames = {"ingot"}
},
lump = {description = S("Lump"), result = "lump", cost = 2, typenames = {"lump"}},
gem = {description = S("Gem"), result = "crystal", cost = 1, typenames = {"crystal", "gem"}}
}
Expand Down Expand Up @@ -444,7 +454,7 @@ function metal_caster.register_cast(name, data)

minetest.register_craftitem(castname, {
description = data.description.." " .. S("Cast") .. "\n\n" .. S("Material Cost: @1", data.cost),
inventory_image = mod.."_"..name.."_cast.png",
inventory_image = data.inventory_image or mod.."_"..name.."_cast.png",
stack_max = 1,
groups = {tinker_cast=1}
})
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion tinkering/nodes/tool_station.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function tool_station.get_formspec(comp_list)

if comp_list then
for _,comp in pairs(comp_list) do
local img = tinkering.components[comp].image .. "^[colorize:#1e1e1e:255"
local component = tinkering.components[comp]
local mod = component.mod_name or "tinkering"
local img = mod.."_"..comp.."_border.png^[colorize:#1e1e1e:alpha"
til = til .. "image[" .. x .. "," .. y .. ";1,1;".. img .. "]"
y = y + 1.25
h = h + 1
Expand Down
2 changes: 1 addition & 1 deletion tinkering/pattern.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function tinkering.register_pattern(name, data)
minetest.register_craftitem(itemname, {
description = desc .. " " .. S("Pattern") .. "\n\n" ..
S("Material Cost: @1", data.cost),
inventory_image = mod.."_" .. name .. "_pattern.png",
inventory_image = data.inventory_image or mod .. "_" .. name .. "_pattern.png",
_tinker_pattern = name,
groups = {tinker_pattern = 1, ["tc_" .. name] = 1}
})
Expand Down
Binary file added tinkering/textures/tinkering_axe_head_border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tinkering/textures/tinkering_axe_head_cast.png
Binary file not shown.
Binary file removed tinkering/textures/tinkering_axe_head_pattern.png
Binary file not shown.
Binary file added tinkering/textures/tinkering_pickaxe_head_border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tinkering/textures/tinkering_pickaxe_head_cast.png
Binary file not shown.
Binary file removed tinkering/textures/tinkering_pickaxe_head_pattern.png
Binary file not shown.
Binary file added tinkering/textures/tinkering_shovel_head_border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tinkering/textures/tinkering_shovel_head_cast.png
Binary file not shown.
Binary file removed tinkering/textures/tinkering_shovel_head_pattern.png
Binary file not shown.
Binary file added tinkering/textures/tinkering_sword_blade_border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tinkering/textures/tinkering_sword_blade_cast.png
Binary file not shown.
Binary file removed tinkering/textures/tinkering_sword_blade_pattern.png
Binary file not shown.
Binary file added tinkering/textures/tinkering_tool_binding_border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tinkering/textures/tinkering_tool_binding_cast.png
Binary file not shown.
Binary file removed tinkering/textures/tinkering_tool_binding_pattern.png
Binary file not shown.
Binary file added tinkering/textures/tinkering_tool_rod_border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tinkering/textures/tinkering_tool_rod_cast.png
Binary file not shown.
Binary file removed tinkering/textures/tinkering_tool_rod_pattern.png
Binary file not shown.
30 changes: 29 additions & 1 deletion tinkering/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -561,20 +561,47 @@ function tinkering.register_material_tool(material)
end
end

local function escape_texture_argument(texture)
return texture:gsub("\\", "\\\\"):gsub("%^", "\\^"):gsub(":", "\\:")
end

local function cut_mold_shape(blank_image, shape_image)
-- Turn the shape into a white inverse-alpha mask, then cut it out of the blank.
local inverse_shape = shape_image.."^[multiply:#000000^[invert:rgba"
return blank_image.."^[mask:"..escape_texture_argument(inverse_shape)
end

local function compose_cast_image(shape_image, border_image)
local cast = cut_mold_shape("metal_melter_blank_cast.png", shape_image)
local border = border_image.."^[colorize:#826800:alpha"
return cast.."^("..border..")"
end

local function compose_pattern_image(shape_image, border_image)
local pattern = cut_mold_shape("tinkering_blank_pattern.png", shape_image)
local border = pattern.."^[multiply:#A0A0A0^[mask:"..
-- Border pixels must be white to preserve colors of blank pattern
escape_texture_argument(border_image--[[ .."^[colorize:#FFFFFF:alpha" --]])
return pattern.."^("..border..")"
end

-- Register a new tool component
function tinkering.register_component(name, data)
local mod = data.mod_name or core.get_current_modname()
data.mod_name = mod

if not tinkering.components[name] then
tinkering.components[name] = data
end

local comp_desc = data.description
local border_image = mod.."_"..name.."_border.png"

-- Register cast
metal_melter.register_melt_value(name, metal_caster.spec.cast)
metal_caster.register_cast(name, {
description = comp_desc,
inventory_image = compose_cast_image(data.image, border_image),
mod_name = mod,
result = name,
cost = data.material_cost,
Expand All @@ -585,7 +612,8 @@ function tinkering.register_component(name, data)
tinkering.register_pattern(name, {
description = comp_desc,
cost = data.material_cost,
mod_name = mod
mod_name = mod,
inventory_image = compose_pattern_image(data.image, border_image)
})

-- Register components for all materials
Expand Down