mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2025-06-28 14:26:21 +02:00
Compare commits
10 Commits
2018-11-09
...
2019-07-18
Author | SHA1 | Date | |
---|---|---|---|
9ff40a7fe6 | |||
e048da9c3c | |||
6c8a0b2387 | |||
10ab87bf65 | |||
f59c8affc1 | |||
667bce80b9 | |||
5039a8ce07 | |||
13a8cbb38f | |||
58dd71e561 | |||
1fd850d37c |
12
API.md
12
API.md
@ -12,7 +12,6 @@ minetest.register_node("mymod:colored_node", {
|
|||||||
paramtype2 = "color",
|
paramtype2 = "color",
|
||||||
palette = "unifieddyes_palette_extended.png",
|
palette = "unifieddyes_palette_extended.png",
|
||||||
groups = {snappy = 1, cracky = 2, ud_param2_colorable = 1}
|
groups = {snappy = 1, cracky = 2, ud_param2_colorable = 1}
|
||||||
on_construct = unifieddyes.on_construct,
|
|
||||||
airbrush_replacement_node = "mymod:my_other_colored_node"
|
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).
|
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.
|
`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
|
#### 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.
|
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)`**
|
**`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:
|
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.
|
* 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",`
|
`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):
|
* 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)
|
* 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.
|
* 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.
|
||||||
|
|
||||||
|
91
init.lua
91
init.lua
@ -128,7 +128,7 @@ unifieddyes.GREYS = {
|
|||||||
unifieddyes.GREYS_EXTENDED = table.copy(unifieddyes.GREYS)
|
unifieddyes.GREYS_EXTENDED = table.copy(unifieddyes.GREYS)
|
||||||
|
|
||||||
for i = 1, 14 do
|
for i = 1, 14 do
|
||||||
if i ~= 0 and i ~= 3 and i ~= 7 and i ~= 11 and i ~= 15 then
|
if i ~= 0 and i ~= 4 and i ~= 8 and i ~= 11 and i ~= 15 then
|
||||||
table.insert(unifieddyes.GREYS_EXTENDED, "grey_"..i)
|
table.insert(unifieddyes.GREYS_EXTENDED, "grey_"..i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -195,6 +195,44 @@ minetest.register_on_placenode(
|
|||||||
end
|
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
|
-- just stubs to keep old mods from crashing when expecting auto-coloring
|
||||||
-- or getting back the dye on dig.
|
-- or getting back the dye on dig.
|
||||||
|
|
||||||
@ -449,7 +487,7 @@ function unifieddyes.getpaletteidx(color, palette_type)
|
|||||||
["grey_14"] = 1,
|
["grey_14"] = 1,
|
||||||
["grey_13"] = 2,
|
["grey_13"] = 2,
|
||||||
["grey_12"] = 3,
|
["grey_12"] = 3,
|
||||||
["light_grey"] = 3,
|
["light_grey"] = 4,
|
||||||
["grey_11"] = 4,
|
["grey_11"] = 4,
|
||||||
["grey_10"] = 5,
|
["grey_10"] = 5,
|
||||||
["grey_9"] = 6,
|
["grey_9"] = 6,
|
||||||
@ -630,6 +668,19 @@ function unifieddyes.getpaletteidx(color, palette_type)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function unifieddyes.get_color_from_dye_name(name)
|
||||||
|
if name == "dye:black" then
|
||||||
|
return "000000"
|
||||||
|
elseif name == "dye:white" then
|
||||||
|
return "ffffff"
|
||||||
|
end
|
||||||
|
local item = minetest.registered_items[name]
|
||||||
|
if not item then return end
|
||||||
|
local inv_image = item.inventory_image
|
||||||
|
if not inv_image then return end
|
||||||
|
return string.match(inv_image,"colorize:#(......):200")
|
||||||
|
end
|
||||||
|
|
||||||
-- punch-to-recolor using the airbrush
|
-- punch-to-recolor using the airbrush
|
||||||
|
|
||||||
function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
||||||
@ -640,8 +691,30 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
|||||||
painting_with = unifieddyes.player_current_dye[player_name]
|
painting_with = unifieddyes.player_current_dye[player_name]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not painting_with then
|
||||||
|
minetest.chat_send_player(player_name, "*** You need to set a color first.")
|
||||||
|
minetest.chat_send_player(player_name, "*** Right-click any random node to open the color selector,")
|
||||||
|
minetest.chat_send_player(player_name, "*** or shift+right-click a colorized node to use its color.")
|
||||||
|
minetest.chat_send_player(player_name, "*** Be sure to click \"Accept\", or the color you select will be ignored.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
||||||
if not pos then return end
|
if not pos then
|
||||||
|
local look_angle = player:get_look_vertical()
|
||||||
|
if look_angle > -1.55 then
|
||||||
|
minetest.chat_send_player(player_name, "*** No node selected")
|
||||||
|
else
|
||||||
|
local hexcolor = unifieddyes.get_color_from_dye_name(painting_with)
|
||||||
|
if hexcolor then
|
||||||
|
local r = tonumber(string.sub(hexcolor,1,2),16)
|
||||||
|
local g = tonumber(string.sub(hexcolor,3,4),16)
|
||||||
|
local b = tonumber(string.sub(hexcolor,5,6),16)
|
||||||
|
player:set_sky({r=r,g=g,b=b,a=255},"plain")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local def = minetest.registered_items[node.name]
|
local def = minetest.registered_items[node.name]
|
||||||
@ -652,14 +725,6 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not painting_with then
|
|
||||||
minetest.chat_send_player(player_name, "*** You need to set a color first.")
|
|
||||||
minetest.chat_send_player(player_name, "*** Right-click any random node to open the color selector,")
|
|
||||||
minetest.chat_send_player(player_name, "*** or shift+right-click a colorized node to use its color.")
|
|
||||||
minetest.chat_send_player(player_name, "*** Be sure to click \"Accept\", or the color you select will be ignored.")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not (def.groups and def.groups.ud_param2_colorable and def.groups.ud_param2_colorable > 0) then
|
if not (def.groups and def.groups.ud_param2_colorable and def.groups.ud_param2_colorable > 0) then
|
||||||
minetest.chat_send_player(player_name, "*** That node can't be colored.")
|
minetest.chat_send_player(player_name, "*** That node can't be colored.")
|
||||||
return
|
return
|
||||||
@ -1102,7 +1167,7 @@ minetest.register_tool("unifieddyes:airbrush", {
|
|||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "unifieddyes:airbrush",
|
output = "unifieddyes:airbrush",
|
||||||
recipe = {
|
recipe = {
|
||||||
{ "default:gold_ingot", "", "bucket:bucket_empty" },
|
{ "basic_materials:brass_ingot", "", "basic_materials:plastic_sheet" },
|
||||||
{ "", "default:steel_ingot", "" },
|
{ "", "default:steel_ingot", "" },
|
||||||
{ "", "", "default:steel_ingot" }
|
{ "", "", "default:steel_ingot" }
|
||||||
},
|
},
|
||||||
@ -1406,7 +1471,7 @@ for _,i in ipairs(unifieddyes.base_color_crafts) do
|
|||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = "dye:"..j[1]..color..j[2].." "..yield,
|
output = "dye:"..j[1]..color..j[2].." "..j[6],
|
||||||
recipe = {
|
recipe = {
|
||||||
"dye:"..color,
|
"dye:"..color,
|
||||||
firstdye,
|
firstdye,
|
||||||
|
74
locale/ru.txt
Normal file
74
locale/ru.txt
Normal 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] загружен!
|
Reference in New Issue
Block a user