From fe299e24d6ad5bb58e077ec372737b117ac6cf94 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 27 May 2022 19:39:36 +0000 Subject: [PATCH] DevTest: Add nodes and items for testing overlays (#12304) --- games/devtest/mods/testitems/init.lua | 55 +++++++++++ games/devtest/mods/testitems/mod.conf | 2 + .../textures/testitems_overlay_base.png | Bin 0 -> 106 bytes .../textures/testitems_overlay_overlay.png | Bin 0 -> 220 bytes games/devtest/mods/testnodes/init.lua | 1 + games/devtest/mods/testnodes/overlays.lua | 93 ++++++++++++++++++ .../testnodes/textures/testnodes_overlay.png | Bin 0 -> 153 bytes .../textures/testnodes_overlayable.png | Bin 0 -> 87 bytes 8 files changed, 151 insertions(+) create mode 100644 games/devtest/mods/testitems/init.lua create mode 100644 games/devtest/mods/testitems/mod.conf create mode 100644 games/devtest/mods/testitems/textures/testitems_overlay_base.png create mode 100644 games/devtest/mods/testitems/textures/testitems_overlay_overlay.png create mode 100644 games/devtest/mods/testnodes/overlays.lua create mode 100644 games/devtest/mods/testnodes/textures/testnodes_overlay.png create mode 100644 games/devtest/mods/testnodes/textures/testnodes_overlayable.png diff --git a/games/devtest/mods/testitems/init.lua b/games/devtest/mods/testitems/init.lua new file mode 100644 index 000000000..33ebf50fc --- /dev/null +++ b/games/devtest/mods/testitems/init.lua @@ -0,0 +1,55 @@ +local S = minetest.get_translator("testitems") + +-- +-- Texture overlays for items +-- + +-- For the global overlay color test +local GLOBAL_COLOR_ARG = "orange" + +-- Punch handler to set random color with "color" argument in item metadata +local overlay_on_use = function(itemstack, user, pointed_thing) + local meta = itemstack:get_meta() + local color = math.random(0x0, 0xFFFFFF) + local colorstr = string.format("#%06x", color) + meta:set_string("color", colorstr) + minetest.log("action", "[testitems] Color of "..itemstack:get_name().." changed to "..colorstr) + return itemstack +end +-- Place handler to clear item metadata color +local overlay_on_place = function(itemstack, user, pointed_thing) + local meta = itemstack:get_meta() + meta:set_string("color", "") + return itemstack +end + +minetest.register_craftitem("testitems:overlay_meta", { + description = S("Texture Overlay Test Item, Meta Color") .. "\n" .. + S("Image must be a square with rainbow cross (inventory and wield)") .. "\n" .. + S("Item meta color must only change square color") .. "\n" .. + S("Punch: Set random color") .. "\n" .. + S("Place: Clear color"), + -- Base texture: A grayscale square (can be colorized) + inventory_image = "testitems_overlay_base.png", + wield_image = "testitems_overlay_base.png", + -- Overlay: A rainbow cross (NOT to be colorized!) + inventory_overlay = "testitems_overlay_overlay.png", + wield_overlay = "testitems_overlay_overlay.png", + + on_use = overlay_on_use, + on_place = overlay_on_place, + on_secondary_use = overlay_on_place, +}) +minetest.register_craftitem("testitems:overlay_global", { + description = S("Texture Overlay Test Item, Global Color") .. "\n" .. + S("Image must be an orange square with rainbow cross (inventory and wield)"), + -- Base texture: A grayscale square (to be colorized) + inventory_image = "testitems_overlay_base.png", + wield_image = "testitems_overlay_base.png", + -- Overlay: A rainbow cross (NOT to be colorized!) + inventory_overlay = "testitems_overlay_overlay.png", + wield_overlay = "testitems_overlay_overlay.png", + color = GLOBAL_COLOR_ARG, +}) + + diff --git a/games/devtest/mods/testitems/mod.conf b/games/devtest/mods/testitems/mod.conf new file mode 100644 index 000000000..f91febe01 --- /dev/null +++ b/games/devtest/mods/testitems/mod.conf @@ -0,0 +1,2 @@ +name = testitems +description = Test mod to test misc. items that are neither tools nor nodes diff --git a/games/devtest/mods/testitems/textures/testitems_overlay_base.png b/games/devtest/mods/testitems/textures/testitems_overlay_base.png new file mode 100644 index 0000000000000000000000000000000000000000..f473623beceb882cf5e982fe4a99d049443cc625 GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|hMq2tAr*|t3haN>r4&r|C^0R_ z-q9|eaJ@i?{lM~v0&Egj9XvM(^;vjLV!PNdX9+LE+zQtD$-mA`1ZrmRboFyt=akR{ E01!DH@&Et; literal 0 HcmV?d00001 diff --git a/games/devtest/mods/testitems/textures/testitems_overlay_overlay.png b/games/devtest/mods/testitems/textures/testitems_overlay_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..75a7d9fc3c58528ed454b68afd2f203618e4f7a1 GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Wq?nJE0F&G|Nj>~y;sIx#1%h^ zD}47=m z^W>+l<+;V{qGi7P6?1ZA$~mAg#pJARCC95@7n9{IS5_}swb)%RbK^$l?xS4gDLgTe~DWM4faB3Jd literal 0 HcmV?d00001