mirror of
https://github.com/mt-mods/unifieddyes.git
synced 2025-06-28 14:26:21 +02:00
Compare commits
11 Commits
2020-02-16
...
2021-01-30
Author | SHA1 | Date | |
---|---|---|---|
6873ad372a | |||
71a35d4d87 | |||
f298584761 | |||
ba7fa97af1 | |||
eb5610fc10 | |||
30c55bec6d | |||
e2c35e6694 | |||
c91c68e0f5 | |||
09f95729c5 | |||
71d7e3c954 | |||
17e87a8162 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
*~
|
|
74
init.lua
74
init.lua
@ -161,18 +161,16 @@ minetest.register_on_placenode(
|
|||||||
|
|
||||||
if not def
|
if not def
|
||||||
or not def.palette
|
or not def.palette
|
||||||
or def.after_place_node then
|
or def.after_place_node
|
||||||
|
or not placer then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local param2
|
||||||
if not string.find(itemstack:to_string(), "palette_index") then
|
if not string.find(itemstack:to_string(), "palette_index") then
|
||||||
local param2
|
|
||||||
local color = 0
|
|
||||||
|
|
||||||
if def.palette == "unifieddyes_palette_extended.png"
|
if def.palette == "unifieddyes_palette_extended.png"
|
||||||
and def.paramtype2 == "color" then
|
and def.paramtype2 == "color" then
|
||||||
param2 = 240
|
param2 = 240
|
||||||
color = 240
|
|
||||||
elseif def.palette == "unifieddyes_palette_colorwallmounted.png"
|
elseif def.palette == "unifieddyes_palette_colorwallmounted.png"
|
||||||
and def.paramtype2 == "colorwallmounted" then
|
and def.paramtype2 == "colorwallmounted" then
|
||||||
param2 = newnode.param2 % 8
|
param2 = newnode.param2 % 8
|
||||||
@ -183,16 +181,21 @@ minetest.register_on_placenode(
|
|||||||
|
|
||||||
if param2 then
|
if param2 then
|
||||||
minetest.swap_node(pos, {name = newnode.name, param2 = param2})
|
minetest.swap_node(pos, {name = newnode.name, param2 = param2})
|
||||||
minetest.get_meta(pos):set_int("palette_index", color)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if def.palette ~= "" then
|
||||||
|
minetest.get_meta(pos):set_int("palette_index", param2 or 240)
|
||||||
|
end
|
||||||
end
|
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
|
||||||
|
|
||||||
local function move_item(item, pos, inv, digger)
|
local function move_item(item, pos, inv, digger, fix_color)
|
||||||
|
if not (digger and digger:is_player()) then return end
|
||||||
local creative = creative_mode or minetest.check_player_privs(digger, "creative")
|
local creative = creative_mode or minetest.check_player_privs(digger, "creative")
|
||||||
|
item = unifieddyes.fix_bad_color_info(item, fix_color)
|
||||||
if inv:room_for_item("main", item)
|
if inv:room_for_item("main", item)
|
||||||
and (not creative or not inv:contains_item("main", item, true)) then
|
and (not creative or not inv:contains_item("main", item, true)) then
|
||||||
inv:add_item("main", item)
|
inv:add_item("main", item)
|
||||||
@ -203,7 +206,7 @@ local function move_item(item, pos, inv, digger)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function unifieddyes.on_dig(pos, node, digger)
|
function unifieddyes.on_dig(pos, node, digger)
|
||||||
|
if not digger then return end
|
||||||
local playername = digger:get_player_name()
|
local playername = digger:get_player_name()
|
||||||
if minetest.is_protected(pos, playername) then
|
if minetest.is_protected(pos, playername) then
|
||||||
minetest.record_protection_violation(pos, playername)
|
minetest.record_protection_violation(pos, playername)
|
||||||
@ -212,20 +215,21 @@ function unifieddyes.on_dig(pos, node, digger)
|
|||||||
|
|
||||||
local oldparam2 = minetest.get_node(pos).param2
|
local oldparam2 = minetest.get_node(pos).param2
|
||||||
local def = minetest.registered_items[node.name]
|
local def = minetest.registered_items[node.name]
|
||||||
local del_color
|
local fix_color
|
||||||
|
|
||||||
if def.paramtype2 == "color" and oldparam2 == 240 and def.palette == "unifieddyes_palette_extended.png" then
|
if def.paramtype2 == "color" and oldparam2 == 240 and def.palette == "unifieddyes_palette_extended.png" then
|
||||||
del_color = true
|
fix_color = 240
|
||||||
|
elseif def.paramtype2 == "color" and oldparam2 == 0 and def.palette == "unifieddyes_palette_extended.png" then
|
||||||
|
fix_color = 0
|
||||||
elseif def.paramtype2 == "colorwallmounted" and math.floor(oldparam2 / 8) == 0 and def.palette == "unifieddyes_palette_colorwallmounted.png" then
|
elseif def.paramtype2 == "colorwallmounted" and math.floor(oldparam2 / 8) == 0 and def.palette == "unifieddyes_palette_colorwallmounted.png" then
|
||||||
del_color = true
|
fix_color = 0
|
||||||
elseif def.paramtype2 == "colorfacedir" and math.floor(oldparam2 / 32) == 0 and string.find(def.palette, "unifieddyes_palette_") then
|
elseif def.paramtype2 == "colorfacedir" and math.floor(oldparam2 / 32) == 0 and string.find(def.palette, "unifieddyes_palette_") then
|
||||||
del_color = true
|
fix_color = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local inv = digger:get_inventory()
|
local inv = digger:get_inventory()
|
||||||
|
if fix_color then
|
||||||
if del_color then
|
move_item(node.name, pos, inv, digger, fix_color)
|
||||||
move_item(node.name, pos, inv, digger)
|
|
||||||
else
|
else
|
||||||
return minetest.node_dig(pos, node, digger)
|
return minetest.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
@ -271,11 +275,14 @@ end
|
|||||||
|
|
||||||
-- This helper function creates a colored itemstack
|
-- This helper function creates a colored itemstack
|
||||||
|
|
||||||
|
function unifieddyes.fix_bad_color_info(item, paletteidx)
|
||||||
|
local stack=minetest.itemstring_with_color(item, paletteidx)
|
||||||
|
return string.gsub(stack, "u0001color", "u0001palette_index")
|
||||||
|
end
|
||||||
|
|
||||||
function unifieddyes.make_colored_itemstack(item, palette, color)
|
function unifieddyes.make_colored_itemstack(item, palette, color)
|
||||||
local paletteidx = unifieddyes.getpaletteidx(color, palette)
|
local paletteidx = unifieddyes.getpaletteidx(color, palette)
|
||||||
local stack = ItemStack(item)
|
return unifieddyes.fix_bad_color_info(item, paletteidx), paletteidx
|
||||||
stack:get_meta():set_int("palette_index", paletteidx)
|
|
||||||
return stack:to_string(),paletteidx
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- these helper functions register all of the recipes needed to create colored
|
-- these helper functions register all of the recipes needed to create colored
|
||||||
@ -891,8 +898,26 @@ local color_button_size = ";0.75,0.75;"
|
|||||||
local color_square_size = ";0.69,0.69;"
|
local color_square_size = ";0.69,0.69;"
|
||||||
|
|
||||||
function unifieddyes.make_readable_color(color)
|
function unifieddyes.make_readable_color(color)
|
||||||
local s = string.gsub(color, "_", " ")
|
-- is this a low saturation color?
|
||||||
s = string.gsub(s, "s50", "(low saturation)")
|
local has_low_saturtation = string.find(color, "s50");
|
||||||
|
|
||||||
|
-- remove _s50 tag, we care about that later again
|
||||||
|
local s = string.gsub(color, "_s50", "")
|
||||||
|
|
||||||
|
-- replace underscores with spaces to make it look nicer
|
||||||
|
local s = string.gsub(s, "_", " ")
|
||||||
|
|
||||||
|
-- capitalize words, you know, looks nicer ;)
|
||||||
|
s = string.gsub(s, "(%l)(%w*)", function(a,b) return string.upper(a)..b end)
|
||||||
|
|
||||||
|
-- add the word dye, this is what the translations expect
|
||||||
|
s = s.." Dye"
|
||||||
|
|
||||||
|
-- if it is a low sat color, append an appropriate string
|
||||||
|
if has_low_saturtation then
|
||||||
|
s = s.." (low saturation)"
|
||||||
|
end
|
||||||
|
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -918,7 +943,7 @@ function unifieddyes.make_colored_square(hexcolor, colorname, showall, creative,
|
|||||||
end
|
end
|
||||||
|
|
||||||
local tooltip = "tooltip["..colorname..";"..
|
local tooltip = "tooltip["..colorname..";"..
|
||||||
unifieddyes.make_readable_color(colorname)..
|
S(unifieddyes.make_readable_color(colorname))..
|
||||||
"\n(dye:"..colorname..")]"
|
"\n(dye:"..colorname..")]"
|
||||||
|
|
||||||
if dye == painting_with then
|
if dye == painting_with then
|
||||||
@ -1096,7 +1121,7 @@ function unifieddyes.show_airbrush_form(player)
|
|||||||
t[#t+1] = "label[10.7,"
|
t[#t+1] = "label[10.7,"
|
||||||
t[#t+1] = (vps*5.07+vs)
|
t[#t+1] = (vps*5.07+vs)
|
||||||
t[#t+1] = ";"
|
t[#t+1] = ";"
|
||||||
t[#t+1] = unifieddyes.make_readable_color(string.sub(painting_with, 5))
|
t[#t+1] = S(unifieddyes.make_readable_color(string.sub(painting_with, 5)))
|
||||||
t[#t+1] = "]label[10.7,"
|
t[#t+1] = "]label[10.7,"
|
||||||
t[#t+1] = (vps*5.24+vs)
|
t[#t+1] = (vps*5.24+vs)
|
||||||
t[#t+1] = ";("
|
t[#t+1] = ";("
|
||||||
@ -1145,10 +1170,11 @@ minetest.register_tool("unifieddyes:airbrush", {
|
|||||||
|
|
||||||
unifieddyes.player_last_right_clicked[player_name] = {pos = pos, node = node, def = def}
|
unifieddyes.player_last_right_clicked[player_name] = {pos = pos, node = node, def = def}
|
||||||
|
|
||||||
if not keys.sneak then
|
if (not keys.sneak) and def.on_rightclick then
|
||||||
|
return def.on_rightclick(pos, node, placer, itemstack, pointed_thing)
|
||||||
|
elseif not keys.sneak then
|
||||||
unifieddyes.show_airbrush_form(placer)
|
unifieddyes.show_airbrush_form(placer)
|
||||||
elseif keys.sneak then
|
elseif keys.sneak then
|
||||||
|
|
||||||
if not pos or not def then return end
|
if not pos or not def then return end
|
||||||
local newcolor = unifieddyes.color_to_name(node.param2, def)
|
local newcolor = unifieddyes.color_to_name(node.param2, def)
|
||||||
|
|
||||||
|
@ -74,3 +74,18 @@ Magenta Dye (low saturation)=Magenta Farbstoff (geringe Saettigung) lila
|
|||||||
Red-violet Dye (low saturation)=Rotvioletter Farbstoff (geringe Saettigung)
|
Red-violet Dye (low saturation)=Rotvioletter Farbstoff (geringe Saettigung)
|
||||||
|
|
||||||
[UnifiedDyes] Loaded!=[UnifiedDyes] geladen!
|
[UnifiedDyes] Loaded!=[UnifiedDyes] geladen!
|
||||||
|
|
||||||
|
Dye Airbrush=Farbstroff Airbrush
|
||||||
|
|
||||||
|
Select a color:=Wähle eine Farbe
|
||||||
|
(Right-clicked a node that supports all 256 colors, showing them all)=(Angeklickter Block unterstützt alle 256 Farben, zeige alle)
|
||||||
|
(Right-clicked a node not supported by the Airbrush, showing all colors)=(Angeklickter Block unterstützt kein Airbrush, zeige alle Farben)
|
||||||
|
Dyes=Farbstoffe
|
||||||
|
Your selection=Deine Auswahl
|
||||||
|
Your selection:=Deine Auswahl:
|
||||||
|
Cancel=Abbrechen
|
||||||
|
Accept=Übernehmen
|
||||||
|
Show Available=Zeige verfügbare
|
||||||
|
(Currently showing all 256 colors)=(Zeige alle 256 Farben)
|
||||||
|
Show All Colors=Zeige alle Farben
|
||||||
|
(Currently only showing what the right-clicked node can use)=(Zeige alle, die der angeklickte Block verwenden kann)
|
||||||
|
1
mod.conf
1
mod.conf
@ -1,3 +1,4 @@
|
|||||||
name = unifieddyes
|
name = unifieddyes
|
||||||
description = Unified Dyes expands the standard dye set from 15 to 90 colors.
|
description = Unified Dyes expands the standard dye set from 15 to 90 colors.
|
||||||
depends = default, dye, basic_materials
|
depends = default, dye, basic_materials
|
||||||
|
min_minetest_version = 5.2.0
|
||||||
|
Reference in New Issue
Block a user