1
0
mirror of https://github.com/mt-mods/unifieddyes.git synced 2025-06-28 22:36:46 +02:00

Compare commits

...

15 Commits

Author SHA1 Message Date
c6883a8300 Merge branch 'fix_drop_fix' into 'master'
prevent crash when dropping item

See merge request VanessaE/unifieddyes!3
2019-09-23 01:49:50 +00:00
22dc40cacc prevent crash when dropping item 2019-09-23 01:49:50 +00:00
9271f07f12 fix incorrect drop behavior when stipping bogus color
in the case of full inv.

Should be the same as normal Minetest behavior now:

In survival mode, the node is deleted, then:

* If there is room in your inv, you get whatever the node
  would normally give you.

* If there's no room, the node drops to the ground as an item
  entity.

In creative mode, the node is deleted, then:

* If you don't already have one of the item, you get one.

* If you already have one, or if there's no room in your
  inventory, "you'll get nothing and LIKE it!" :-)

Also: made sure to check for creative priv as well as proper
creative mode.
2019-09-15 23:57:58 -04:00
0082b1513a remove an obsolete function reference 2019-07-20 04:29:31 -04:00
d59ccd3298 document the new on_dig function 2019-07-20 04:28:53 -04:00
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
10ab87bf65 prevent crash in setting sky color
if get color from name return nil
2019-05-25 04:14:12 -04:00
f59c8affc1 Merge branch 'master' into 'master'
Fixed yield for crafted dyes.

See merge request VanessaE/unifieddyes!2
2019-02-07 15:19:47 +00:00
667bce80b9 Fixed yield for crafted dyes.
Fix a bug that caused multiple inconsistent recipes to appear
(identical dye resources gave different dye output quantity).

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
2019-02-07 10:08:04 +01:00
5039a8ce07 Merge branch 'patch-1' into 'master'
Fix numbers relating to greys

See merge request VanessaE/unifieddyes!1
2018-12-16 00:09:21 +00:00
13a8cbb38f Some of the numbers relating to greys are used inconsistently, making three of the palette colours unreachable. This bug patch fixes the numbers and restores full usability of the palette. 2018-12-15 10:53:35 +00:00
58dd71e561 Add function to get the hex color from a dye name
(oh, and https://www.youtube.com/watch?v=OEVFbrEv83w too)
2018-12-01 17:59:00 -06:00
1fd850d37c change airbrush recipe
to 1 brass ingot, 2 steel ingots, and 1 plastic sheet
2018-11-23 10:38:05 -05:00
3 changed files with 168 additions and 29 deletions

24
API.md
View File

@ -12,8 +12,8 @@ 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"
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).
`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
**`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_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.
**`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:
@ -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).
#### 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
place_param2 = 240,
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.
@ -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.
* 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 +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)
* 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

@ -128,7 +128,7 @@ unifieddyes.GREYS = {
unifieddyes.GREYS_EXTENDED = table.copy(unifieddyes.GREYS)
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)
end
end
@ -195,6 +195,48 @@ 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, 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(ItemStack(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
-- or getting back the dye on dig.
@ -449,7 +491,7 @@ function unifieddyes.getpaletteidx(color, palette_type)
["grey_14"] = 1,
["grey_13"] = 2,
["grey_12"] = 3,
["light_grey"] = 3,
["light_grey"] = 4,
["grey_11"] = 4,
["grey_10"] = 5,
["grey_9"] = 6,
@ -630,6 +672,19 @@ function unifieddyes.getpaletteidx(color, palette_type)
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
function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
@ -640,8 +695,30 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
painting_with = unifieddyes.player_current_dye[player_name]
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)
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 def = minetest.registered_items[node.name]
@ -652,14 +729,6 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing)
return
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
minetest.chat_send_player(player_name, "*** That node can't be colored.")
return
@ -1102,9 +1171,9 @@ minetest.register_tool("unifieddyes:airbrush", {
minetest.register_craft( {
output = "unifieddyes:airbrush",
recipe = {
{ "default:gold_ingot", "", "bucket:bucket_empty" },
{ "", "default:steel_ingot", "" },
{ "", "", "default:steel_ingot" }
{ "basic_materials:brass_ingot", "", "basic_materials:plastic_sheet" },
{ "", "default:steel_ingot", "" },
{ "", "", "default:steel_ingot" }
},
})
@ -1406,7 +1475,7 @@ for _,i in ipairs(unifieddyes.base_color_crafts) do
minetest.register_craft( {
type = "shapeless",
output = "dye:"..j[1]..color..j[2].." "..yield,
output = "dye:"..j[1]..color..j[2].." "..j[6],
recipe = {
"dye:"..color,
firstdye,

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] загружен!