From 5f6d3bba2a3ba1882290b136d500172036e4182c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Juh=C3=A1sz?= Date: Sat, 24 Jun 2017 18:15:09 +0000 Subject: [PATCH] Helper methods for hardware colorization (#5870) --- builtin/game/item.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/builtin/game/item.lua b/builtin/game/item.lua index f6de2c3..59ec5ff 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -572,6 +572,18 @@ function core.node_dig(pos, node, digger) end end +function core.itemstring_with_palette(item, palette_index) + local stack = ItemStack(item) -- convert to ItemStack + stack:get_meta():set_int("palette_index", palette_index) + return stack:to_string() +end + +function core.itemstring_with_color(item, colorstring) + local stack = ItemStack(item) -- convert to ItemStack + stack:get_meta():set_string("color", colorstring) + return stack:to_string() +end + -- This is used to allow mods to redefine core.item_place and so on -- NOTE: This is not the preferred way. Preferred way is to provide enough -- callbacks to not require redefining global functions. -celeron55