1
0
mirror of https://github.com/mt-mods/unifieddyes.git synced 2025-07-20 09:10:29 +02:00

Compare commits

...

6 Commits

4 changed files with 203 additions and 28 deletions

View File

@ -473,7 +473,7 @@ end)
minetest.register_tool("unifieddyes:airbrush", {
description = S("Dye Airbrush"),
inventory_image = "unifieddyes_airbrush.png",
use_texture_alpha = true,
use_texture_alpha = core.features.use_texture_alpha_string_modes and "opaque" or true,
tool_capabilities = {
full_punch_interval=0.1,
},

136
api.lua
View File

@ -45,46 +45,129 @@ minetest.register_on_placenode(
end
)
-- The complementary function: strip-off the color if the node being dug is still white/neutral
-- The complementary function: strip-off the color if the node being dug is still white/neutral
-- adapted from
-- https://github.com/minetest/minetest/blob/fe8d04d0b3c2e3af7c406fb6527f1b5230a30137/builtin/game/item.lua#L460-L562
local function node_dig_without_color(pos, node, digger)
if not digger then return false end
local diggername = digger:get_player_name()
local function move_item(item, pos, inv, digger)
if not (digger and digger:is_player()) then return end
local creative = minetest.is_creative_enabled(digger:get_player_name())
if inv:room_for_item("main", item)
and (not creative or not inv:contains_item("main", item, true)) then
inv:add_item("main", item)
elseif not creative then
minetest.item_drop(ItemStack(item), digger, pos)
local def = ItemStack(node.name):get_definition()
-- Copy pos because the callback could modify it
if not def.diggable or (def.can_dig and not def.can_dig(vector.copy(pos), digger)) then
minetest.log("info", diggername .. " tried to dig "
.. node.name .. " which is not diggable "
.. minetest.pos_to_string(pos))
return false
end
if minetest.is_protected(pos, diggername) then
minetest.log("action", diggername
.. " tried to dig " .. node.name
.. " at protected position "
.. minetest.pos_to_string(pos))
minetest.record_protection_violation(pos, diggername)
return false
end
minetest.log('action', diggername .. " digs "
.. node.name .. " at " .. minetest.pos_to_string(pos))
local wielded = digger and digger:get_wielded_item()
local drops = {node.name} -- this is instead of asking minetest to generate the node drops
if wielded then
local wdef = wielded:get_definition()
local tp = wielded:get_tool_capabilities()
local dp = minetest.get_dig_params(def and def.groups, tp, wielded:get_wear())
if wdef and wdef.after_use then
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
else
-- Wear out tool
if not minetest.is_creative_enabled(diggername) then
wielded:add_wear(dp.wear)
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
minetest.sound_play(wdef.sound.breaks, {
pos = pos,
gain = 0.5
}, true)
end
end
end
digger:set_wielded_item(wielded)
end
-- Check to see if metadata should be preserved.
if def and def.preserve_metadata then
local oldmeta = minetest.get_meta(pos):to_table().fields
-- Copy pos and node because the callback can modify them.
local pos_copy = vector.copy(pos)
local node_copy = { name = node.name, param1 = node.param1, param2 = node.param2 }
local drop_stacks = {}
for k, v in pairs(drops) do
drop_stacks[k] = ItemStack(v)
end
drops = drop_stacks
def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
end
-- Handle drops
minetest.handle_node_drops(pos, drops, digger)
local oldmetadata
if def and def.after_dig_node then
oldmetadata = minetest.get_meta(pos):to_table()
end
-- Remove node and update
minetest.remove_node(pos)
-- Play sound if it was done by a player
if diggername ~= "" and def and def.sounds and def.sounds.dug then
minetest.sound_play(def.sounds.dug, {
pos = pos,
exclude_player = diggername,
}, true)
end
-- Run callback
if def and def.after_dig_node then
-- Copy pos and node because callback can modify them
local pos_copy = vector.copy(pos)
local node_copy = { name = node.name, param1 = node.param1, param2 = node.param2 }
def.after_dig_node(pos_copy, node_copy, oldmetadata, digger)
end
-- Run script hook
for _, callback in ipairs(minetest.registered_on_dignodes) do
local origin = minetest.callback_origins[callback]
minetest.set_last_run_mod(origin.mod)
-- Copy pos and node because callback can modify them
local pos_copy = vector.copy(pos)
local node_copy = { name = node.name, param1 = node.param1, param2 = node.param2 }
callback(pos_copy, node_copy, digger)
end
return true
end
function unifieddyes.on_dig(pos, node, digger)
if not digger then return end
local playername = digger:get_player_name()
if minetest.is_protected(pos, playername) then
minetest.record_protection_violation(pos, playername)
return
end
local oldparam2 = minetest.get_node(pos).param2
local param2 = minetest.get_node(pos).param2
local def = minetest.registered_items[node.name]
local del_color
if def.paramtype2 == "color" and oldparam2 == 240 and def.palette == "unifieddyes_palette_extended.png" then
if def.paramtype2 == "color" and param2 == 240 and def.palette == "unifieddyes_palette_extended.png" then
del_color = true
elseif def.paramtype2 == "colorwallmounted" and math.floor(oldparam2 / 8) == 0
and def.palette == "unifieddyes_palette_colorwallmounted.png" then
del_color = true
elseif def.paramtype2 == "colorfacedir" and math.floor(oldparam2 / 32) == 0
and string.find(def.palette, "unifieddyes_palette_") then
elseif (def.paramtype2 == "colorwallmounted" or def.paramtype2 == "colorfacedir")
and minetest.strip_param2_color(param2, def.paramtype2) == 0
and string.find(def.palette, "unifieddyes_palette_")
then
del_color = true
end
local inv = digger:get_inventory()
if del_color then
move_item(node.name, pos, inv, digger)
return node_dig_without_color(pos, node, digger)
else
return minetest.node_dig(pos, node, digger)
end
@ -115,6 +198,7 @@ function unifieddyes.generate_split_palette_nodes(name, def, drop)
def2.palette = "unifieddyes_palette_"..color.."s.png"
def2.paramtype2 = "colorfacedir"
def2.groups.ud_param2_colorable = 1
def2.is_ground_content = false
if drop then
def2.drop = {

View File

@ -0,0 +1,91 @@
# textdomain: unifieddyes
# Translation by W0rr1z
Lime Dye=柠檬黄染料
Aqua Dye=水蓝染料
Sky-blue Dye=天蓝染料
Red-violet Dye=红紫染料
Light Grey Dye=浅灰染料
Dark Red Dye (low saturation)=深红染料(低饱和度)
Dark Orange Dye (low saturation)=深橙染料(低饱和度)
Dark Yellow Dye (low saturation)=深黄染料(低饱和度)
Dark Lime Dye (low saturation)=深柠檬黄染料(低饱和度)
Dark Green Dye (low saturation)=深绿染料(低饱和度)
Dark Aqua Dye (low saturation)=深水蓝染料(低饱和度)
Dark Cyan Dye (low saturation)=深青蓝染料(低饱和度)
Dark Sky-blue Dye (low saturation)=深天蓝染料(低饱和度)
Dark Blue Dye (low saturation)=深蓝染料(低饱和度)
Dark Violet Dye (low saturation)=深紫染料(低饱和度)
Dark Magenta Dye (low saturation)=深品红染料(低饱和度)
Dark Red-violet Dye (low saturation)=深红紫染料(低饱和度)
Dark Red Dye=深红染料
Dark Orange Dye=深橙染料
Dark Yellow Dye=深黄染料
Dark Lime Dye=深柠檬黄染料
Dark Green Dye=深绿染料
Dark Aqua Dye=深水蓝染料
Dark Cyan Dye=深青蓝染料
Dark Sky-blue Dye=深天蓝染料
Dark Blue Dye=深蓝染料
Dark Violet Dye=深紫染料
Dark Magenta Dye=深品红染料
Dark Red-violet Dye=深红紫染料
Medium Red Dye (low saturation)=中红染料(低饱和度)
Medium Orange Dye (low saturation)=中橙染料(低饱和度)
Medium Yellow Dye (low saturation)=中黄染料(低饱和度)
Medium Lime Dye (low saturation)=中柠檬黄染料(低饱和度)
Medium Green Dye (low saturation)=中绿染料(低饱和度)
Medium Aqua Dye (low saturation)=中水蓝染料(低饱和度)
Medium Cyan Dye (low saturation)=中青蓝染料(低饱和度)
Medium Sky-blue Dye (low saturation)=中天蓝染料(低饱和度)
Medium Blue Dye (low saturation)=中蓝染料(低饱和度)
Medium Violet Dye (low saturation)=中紫染料(低饱和度)
Medium Magenta Dye (low saturation)=中品红染料(低饱和度)
Medium Red-violet Dye (low saturation)=中红紫染料(低饱和度)
Medium Red Dye=中红染料
Medium Orange Dye=中橙染料
Medium Yellow Dye=中黄染料
Medium Lime Dye=中柠檬黄染料
Medium Green Dye=中绿染料
Medium Aqua Dye=中水蓝染料
Medium Cyan Dye=中青蓝染料
Medium Sky-blue=中天蓝染料
Medium Blue Dye=中蓝染料
Medium Violet Dye=中紫染料
Medium Magenta Dye=中品红染料
Medium Red-violet Dye=中红紫染料
Red Dye (low saturation)=红染料(低饱和度)
Orange Dye (low saturation)=橙染料(低饱和度)
Yellow Dye (low saturation)=黄染料(低饱和度)
Lime Dye (low saturation)=柠檬黄染料(低饱和度)
Green Dye (low saturation)=绿染料(低饱和度)
Aqua Dye (low saturation)=水蓝染料(低饱和度)
Cyan Dye (low saturation)=青蓝染料(低饱和度)
Sky-blue Dye (low saturation)=天蓝染料(低饱和度)
Blue Dye (low saturation)=蓝染料(低饱和度)
Violet Dye (low saturation)=紫染料(低饱和度)
Magenta Dye (low saturation)=品红染料(低饱和度)
Red-violet Dye (low saturation)=红紫染料(低饱和度)
[UnifiedDyes] Loaded!=[UnifiedDyes] 已加载!
Dye Airbrush=染料喷枪
Select a color:=选择颜色:
(Right-clicked a node that supports all 256 colors, showing them all)=已右键支持256色的方块显示全部颜色
(Right-clicked a node not supported by the Airbrush, showing all colors)=(已右键不支持喷枪的方块,显示全部颜色)
Dyes=染料
Your selection=当前选择
Your selection:=当前选择:
Cancel=取消
Accept=应用
Show Available=显示可用颜色
(Currently showing all 256 colors)=当前显示全部256色
Show All Colors=显示所有颜色
(Currently only showing what the right-clicked node can use)=(当前仅显示右键方块可用颜色)

View File

@ -1,4 +1,4 @@
name = unifieddyes
description = Unified Dyes expands the standard dye set from 15 to 90 colors.
optional_depends = default, dye, basic_materials
min_minetest_version = 5.3.0
min_minetest_version = 5.5.0