mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
DevTest: Add nodes and items for testing overlays (#12304)
This commit is contained in:
parent
ef22c0206f
commit
fe299e24d6
55
games/devtest/mods/testitems/init.lua
Normal file
55
games/devtest/mods/testitems/init.lua
Normal file
@ -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,
|
||||
})
|
||||
|
||||
|
2
games/devtest/mods/testitems/mod.conf
Normal file
2
games/devtest/mods/testitems/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = testitems
|
||||
description = Test mod to test misc. items that are neither tools nor nodes
|
BIN
games/devtest/mods/testitems/textures/testitems_overlay_base.png
Normal file
BIN
games/devtest/mods/testitems/textures/testitems_overlay_base.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 B |
Binary file not shown.
After Width: | Height: | Size: 220 B |
@ -8,3 +8,4 @@ dofile(path.."/properties.lua")
|
||||
dofile(path.."/liquids.lua")
|
||||
dofile(path.."/light.lua")
|
||||
dofile(path.."/textures.lua")
|
||||
dofile(path.."/overlays.lua")
|
||||
|
93
games/devtest/mods/testnodes/overlays.lua
Normal file
93
games/devtest/mods/testnodes/overlays.lua
Normal file
@ -0,0 +1,93 @@
|
||||
local S = minetest.get_translator("testnodes")
|
||||
|
||||
minetest.register_node("testnodes:overlay", {
|
||||
description = S("Texture Overlay Test Node") .. "\n" ..
|
||||
S("Uncolorized"),
|
||||
tiles = {{name = "testnodes_overlayable.png"}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png"}},
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
||||
minetest.register_node("testnodes:overlay_color_all", {
|
||||
description = S("Texture Overlay Test Node, Colorized") .. "\n" ..
|
||||
S("param2 changes color"),
|
||||
tiles = {{name = "testnodes_overlayable.png"}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png"}},
|
||||
paramtype2 = "color",
|
||||
palette = "testnodes_palette_full.png",
|
||||
|
||||
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
||||
minetest.register_node("testnodes:overlay_color_overlay", {
|
||||
description = S("Texture Overlay Test Node, Colorized Overlay") .. "\n" ..
|
||||
S("param2 changes color of overlay"),
|
||||
tiles = {{name = "testnodes_overlayable.png", color="white"}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png"}},
|
||||
paramtype2 = "color",
|
||||
palette = "testnodes_palette_full.png",
|
||||
|
||||
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
||||
minetest.register_node("testnodes:overlay_color_overlayed", {
|
||||
description = S("Texture Overlay Test Node, Colorized Base") .. "\n" ..
|
||||
S("param2 changes color of base texture"),
|
||||
tiles = {{name = "testnodes_overlayable.png"}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png", color="white"}},
|
||||
paramtype2 = "color",
|
||||
palette = "testnodes_palette_full.png",
|
||||
|
||||
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
||||
|
||||
local global_overlay_color = "#FF2000"
|
||||
minetest.register_node("testnodes:overlay_global", {
|
||||
description = S("Texture Overlay Test Node, Global Color") .. "\n" ..
|
||||
S("Global color = @1", global_overlay_color),
|
||||
tiles = {{name = "testnodes_overlayable.png"}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png"}},
|
||||
color = global_overlay_color,
|
||||
|
||||
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
||||
minetest.register_node("testnodes:overlay_global_color_all", {
|
||||
description = S("Texture Overlay Test Node, Global Color + Colorized") .. "\n" ..
|
||||
S("Global color = @1", global_overlay_color) .. "\n" ..
|
||||
S("param2 changes color"),
|
||||
tiles = {{name = "testnodes_overlayable.png"}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png"}},
|
||||
color = global_overlay_color,
|
||||
paramtype2 = "color",
|
||||
palette = "testnodes_palette_full.png",
|
||||
|
||||
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
||||
minetest.register_node("testnodes:overlay_global_color_overlay", {
|
||||
description = S("Texture Overlay Test Node, Global Color + Colorized Overlay") .. "\n" ..
|
||||
S("Global color = @1", global_overlay_color) .. "\n" ..
|
||||
S("param2 changes color of overlay"),
|
||||
tiles = {{name = "testnodes_overlayable.png", color=global_overlay_color}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png"}},
|
||||
color = global_overlay_color,
|
||||
paramtype2 = "color",
|
||||
palette = "testnodes_palette_full.png",
|
||||
|
||||
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
||||
minetest.register_node("testnodes:overlay_global_color_overlayed", {
|
||||
description = S("Texture Overlay Test Node, Global Color + Colorized Base") .. "\n" ..
|
||||
S("Global color = @1", global_overlay_color) .. "\n" ..
|
||||
S("param2 changes color of base texture"),
|
||||
tiles = {{name = "testnodes_overlayable.png"}},
|
||||
overlay_tiles = {{name = "testnodes_overlay.png", color=global_overlay_color}},
|
||||
color = global_overlay_color,
|
||||
paramtype2 = "color",
|
||||
palette = "testnodes_palette_full.png",
|
||||
|
||||
|
||||
groups = { dig_immediate = 2 },
|
||||
})
|
BIN
games/devtest/mods/testnodes/textures/testnodes_overlay.png
Normal file
BIN
games/devtest/mods/testnodes/textures/testnodes_overlay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 153 B |
BIN
games/devtest/mods/testnodes/textures/testnodes_overlayable.png
Normal file
BIN
games/devtest/mods/testnodes/textures/testnodes_overlayable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 B |
Loading…
Reference in New Issue
Block a user