1
0
mirror of https://github.com/mt-mods/unifieddyes.git synced 2025-06-28 14:26:21 +02:00

Compare commits

..

3 Commits

Author SHA1 Message Date
9ff40a7fe6 Add a helper function to reset a node's/item's color info
if a neutral node somehow ends up with different itemstack
meta when placed and then later dug.  Prevents look-alike stacks.
2019-07-18 02:00:56 -04:00
e048da9c3c remove mentions of on_construct
(outdated, no longer valid or necessary)
2019-07-07 15:53:03 -04:00
6c8a0b2387 Add Russian translations 2019-06-26 10:27:48 -04:00
3 changed files with 114 additions and 10 deletions

12
API.md
View File

@ -12,7 +12,6 @@ minetest.register_node("mymod:colored_node", {
paramtype2 = "color",
palette = "unifieddyes_palette_extended.png",
groups = {snappy = 1, cracky = 2, ud_param2_colorable = 1}
on_construct = unifieddyes.on_construct,
airbrush_replacement_node = "mymod:my_other_colored_node"
})
```
@ -32,8 +31,6 @@ minetest.register_node("mymod:colored_node", {
If your node if of the kind where you need the split palette, but you need to put the *full color name* into the node name, as opposed to just the hue, then add the keys `ud_color_start` and `ud_color_end` and set them to the positions of the first and last characters of the color name (where 1 is the first character of the mod name at the start of the node name, i.e. "mymod:foo_bar_orange_baz" would have the start set to 15 and the end at 20).
`on_construct`: see below.
`airbrush_replacement_node`: The node to swap in when the airbrush is used on this node. For example, you could `minetest.override_item()` on some default node to add this field, pointing to a colorable node of your own, so that when the default node is painted, it's replaced with yours in the new color.
#### Function calls
@ -86,10 +83,6 @@ This is called when a node is punched while wielding the airbrush.
This one does just what it sounds like - it shows the color selector formspec.
**`unifieddyes.on_construct(pos)`**
This function, usually called from your node definition's `on_construct`, just sets the `palette = "ext"` metadata key for the node after it's been placed. This can then be read in an LBM to determine if this node needs to be converted from the old 89-color palette to the extended 256-color palette. Although it is good practice to call this for any node that uses the 256-color palette, it isn't actually necessary as long as the node has never used the 89-color palette, and won't be subjected to an LBM that changes its color.
**`unifieddyes.register_color_craft(recipe)`**
This will loop through all of Unified Dyes' color lists, generating one recipe for every color in the palette given in the call. Example usage:
@ -167,10 +160,9 @@ If your mod used the old paradigm where you craft a neutral-colored item, place
* Convert that remaining texture to grayscale, enhance its contrast as much as you can without distorting it, and rename it and the node it'll be used to something neutral-sounding.
* Add the `on_construct` and `palette` keys to your neutral node definition, for example:
* Add the `palette` key to your neutral node definition, for example:
`palette = "unifieddyes_palette_extended.png",`
`on_construct = unifieddyes.on_construct,`
* Adjust your node's groups to specify that the node can be colored. Example (note the last item):
@ -180,7 +172,7 @@ If your mod used the old paradigm where you craft a neutral-colored item, place
* Add the above recipes helper call (which replaces those delted recipes)
* If your colored node is based on someone else's neutral node, for example if you made a mod that creates multiple colors of minetest_game's default clay, you may find it best to create a single "stand-in" node that's identical to the neutral node, but named for your mod, hidden from the creative inventory, and which has a properly-prepared grayscale texture image in addition to the above keys. Use `minetest.override_item()` to add the `on_construct`, `palette`, and `airbrush_replacement_node` keys, and the `ud_param2_colorable` group, to that "someone else's" node. Then use that node and your custom, hidden node in the craft helper call.
* If your colored node is based on someone else's neutral node, for example if you made a mod that creates multiple colors of minetest_game's default clay, you may find it best to create a single "stand-in" node that's identical to the neutral node, but named for your mod, hidden from the creative inventory, and which has a properly-prepared grayscale texture image in addition to the above keys. Use `minetest.override_item()` to add the `palette` and `airbrush_replacement_node` keys, and the `ud_param2_colorable` group, to that "someone else's" node. Then use that node and your custom, hidden node in the craft helper call.
* You will need to write a run-only-once LBM to convert your old statically-colored nodes to use hardware coloring. See above for functions that will help reduce the work required for this part.

View File

@ -195,6 +195,44 @@ minetest.register_on_placenode(
end
)
-- The complementary function: strip-off the color if the node being dug is still white/neutral
local function move_item(item, pos, inv)
if not creative_mode or not inv:contains_item("main", item, true) then
inv:add_item("main", item)
end
minetest.remove_node(pos)
end
function unifieddyes.on_dig(pos, node, digger)
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 def = minetest.registered_items[node.name]
local del_color
if def.paramtype2 == "color" and oldparam2 == 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
del_color = true
end
local inv = digger:get_inventory()
if del_color then
if inv:room_for_item("main", node.name) then move_item(node.name, pos, inv) end
else
return minetest.node_dig(pos, node, digger)
end
end
-- just stubs to keep old mods from crashing when expecting auto-coloring
-- or getting back the dye on dig.

74
locale/ru.txt Normal file
View File

@ -0,0 +1,74 @@
# Translation by @drakes_journey
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] загружен!