aboutsummaryrefslogtreecommitdiff
path: root/builtin/game/item.lua
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2017-06-24 18:15:09 +0000
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-24 20:15:09 +0200
commit5a41a98ff6ac899038bfc359912ebb021479451b (patch)
treeb937d7cb348aa198c6b8d666cebf52e736d8ed87 /builtin/game/item.lua
parentc2df1a08351101034f52fd2810051715714c9c40 (diff)
downloadhax-minetest-server-5a41a98ff6ac899038bfc359912ebb021479451b.tar.gz
hax-minetest-server-5a41a98ff6ac899038bfc359912ebb021479451b.zip
Helper methods for hardware colorization (#5870)
Diffstat (limited to 'builtin/game/item.lua')
-rw-r--r--builtin/game/item.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/game/item.lua b/builtin/game/item.lua
index f6de2c339..59ec5ff65 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