mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2025-06-28 14:26:21 +02:00
Compare commits
11 Commits
2018-12-03
...
2019-09-15
Author | SHA1 | Date | |
---|---|---|---|
9271f07f12 | |||
0082b1513a | |||
d59ccd3298 | |||
9ff40a7fe6 | |||
e048da9c3c | |||
6c8a0b2387 | |||
10ab87bf65 | |||
f59c8affc1 | |||
667bce80b9 | |||
5039a8ce07 | |||
13a8cbb38f |
24
API.md
24
API.md
@ -12,8 +12,8 @@ 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"
|
on_dig = unifieddyes.on_dig
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -32,12 +32,14 @@ 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
|
||||||
|
|
||||||
|
**`unifieddyes.on_dig(pos, node, digger)`**
|
||||||
|
|
||||||
|
Set in a node definition's `on_dig` callback, this makes sure that if the player digs a neutral node, i.e. a colorable node that was left uncolored/white after placing, they receive a version of that item that has been stripped of its itemstack color setting, so that it is identical to what would have been in their inventory when that node was originally placed. This prevents the engine splitting stacks of that item due to technically-different but visually-identical itemstack coloring. This function is only needed in the definition of colorable versions of a node, not any uncolored counterparts. For example, if you have a mod that has a simple, wooden chair, and the mod turns it into one with a colored seat cushion when you airbrush or craft it with dye, then only that latter colored-seat version needs this function.
|
||||||
|
|
||||||
**`unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)`
|
**`unifieddyes.fix_rotation(pos, placer, itemstack, pointed_thing)`
|
||||||
`unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing)`**
|
`unifieddyes.fix_rotation_nsew(pos, placer, itemstack, pointed_thing)`**
|
||||||
|
|
||||||
@ -86,10 +88,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:
|
||||||
@ -127,7 +125,6 @@ Makes a colored itemstack out of the given `itemstack` and `color` (as a dye, e.
|
|||||||
|
|
||||||
Does just what it sounds like - it registers all the nodes that are needed for a given base node (`def`) to be able to use the split palette, each named according to `name`, with the palette hue appended. If a custom drop is needed, it can be passed along (only a string is allowed here, specifying a single item).
|
Does just what it sounds like - it registers all the nodes that are needed for a given base node (`def`) to be able to use the split palette, each named according to `name`, with the palette hue appended. If a custom drop is needed, it can be passed along (only a string is allowed here, specifying a single item).
|
||||||
|
|
||||||
|
|
||||||
#### Tables
|
#### Tables
|
||||||
|
|
||||||
In addition to the above API calls, Unified Dyes provides several useful tables
|
In addition to the above API calls, Unified Dyes provides several useful tables
|
||||||
@ -151,8 +148,8 @@ If your mod used the old paradigm where you craft a neutral-colored item, place
|
|||||||
```lua
|
```lua
|
||||||
place_param2 = 240,
|
place_param2 = 240,
|
||||||
after_dig_node = unifieddyes.after_dig_node,
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
after_place_node = unifieddyes.recolor_on_place,
|
ud_replacement_node = "mod:some_node",
|
||||||
ud_replacement_node = "mod:some_node"
|
on_dig = unifieddyes.on_dig
|
||||||
```
|
```
|
||||||
|
|
||||||
* Add the `airbrush_replacement_node` key to the node definition, if needed.
|
* Add the `airbrush_replacement_node` key to the node definition, if needed.
|
||||||
@ -167,10 +164,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 +176,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.
|
||||||
|
|
||||||
|
58
init.lua
58
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,48 @@ 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, digger)
|
||||||
|
local creative = creative_mode or minetest.check_player_privs(digger, "creative")
|
||||||
|
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(item, digger, pos)
|
||||||
|
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
|
||||||
|
move_item(node.name, pos, inv, digger)
|
||||||
|
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 +491,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,
|
||||||
@ -668,10 +710,12 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
|
|||||||
minetest.chat_send_player(player_name, "*** No node selected")
|
minetest.chat_send_player(player_name, "*** No node selected")
|
||||||
else
|
else
|
||||||
local hexcolor = unifieddyes.get_color_from_dye_name(painting_with)
|
local hexcolor = unifieddyes.get_color_from_dye_name(painting_with)
|
||||||
local r = tonumber(string.sub(hexcolor,1,2),16)
|
if hexcolor then
|
||||||
local g = tonumber(string.sub(hexcolor,3,4),16)
|
local r = tonumber(string.sub(hexcolor,1,2),16)
|
||||||
local b = tonumber(string.sub(hexcolor,5,6),16)
|
local g = tonumber(string.sub(hexcolor,3,4),16)
|
||||||
player:set_sky({r=r,g=g,b=b,a=255},"plain")
|
local b = tonumber(string.sub(hexcolor,5,6),16)
|
||||||
|
player:set_sky({r=r,g=g,b=b,a=255},"plain")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -1431,7 +1475,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