Name colors by number
This commit is contained in:
parent
88babb1e27
commit
b133631018
11
init.lua
11
init.lua
@ -1,5 +1,10 @@
|
|||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
|
local function set_color(meta, color)
|
||||||
|
meta:set_int("palette_index", color)
|
||||||
|
meta:set_string("description", "Dye (color #" .. color .. ")")
|
||||||
|
end
|
||||||
|
|
||||||
local function change_variation(itemstack)
|
local function change_variation(itemstack)
|
||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
local color = meta:get_int("palette_index")
|
local color = meta:get_int("palette_index")
|
||||||
@ -16,7 +21,7 @@ local function change_variation(itemstack)
|
|||||||
local hue = color - variation
|
local hue = color - variation
|
||||||
new_color = (variation+1) % 10 + hue
|
new_color = (variation+1) % 10 + hue
|
||||||
end
|
end
|
||||||
meta:set_int("palette_index", new_color)
|
set_color(meta, new_color)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -31,7 +36,7 @@ local function change_hue(itemstack)
|
|||||||
new_color = math.max(color + 1, 240)
|
new_color = math.max(color + 1, 240)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
meta:set_int("palette_index", new_color)
|
set_color(meta, new_color)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -124,7 +129,7 @@ local function dye_craft(itemstack, player, old_craft_grid, craft_inv)
|
|||||||
itemstack = ItemStack("256_dyes:dye " .. #list_colors)
|
itemstack = ItemStack("256_dyes:dye " .. #list_colors)
|
||||||
local new_color = mix(unpack(list_colors))
|
local new_color = mix(unpack(list_colors))
|
||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
meta:set_int("palette_index", new_color)
|
set_color(meta, new_color)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user