aboutsummaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorZughy <63455151+Zughy@users.noreply.github.com>2020-12-14 23:49:30 +0100
committerGitHub <noreply@github.com>2020-12-14 23:49:30 +0100
commit4d41ed09750c7a2fbfeeeccb7a2c3452e3dd26dc (patch)
tree83ce2e1d2057fc1d23e30820d91dd15c4029fe66 /games
parentf2c8c6bf51e608ad6f71710032b8ae017b84fd3d (diff)
downloadminetest-4d41ed09750c7a2fbfeeeccb7a2c3452e3dd26dc.tar.gz
minetest-4d41ed09750c7a2fbfeeeccb7a2c3452e3dd26dc.tar.bz2
minetest-4d41ed09750c7a2fbfeeeccb7a2c3452e3dd26dc.zip
Semi-transparent background for nametags (#10152)
Diffstat (limited to 'games')
-rw-r--r--games/devtest/mods/testentities/visuals.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/games/devtest/mods/testentities/visuals.lua b/games/devtest/mods/testentities/visuals.lua
index 8848ba49f..e3b758329 100644
--- a/games/devtest/mods/testentities/visuals.lua
+++ b/games/devtest/mods/testentities/visuals.lua
@@ -94,3 +94,32 @@ minetest.register_entity("testentities:upright_animated", {
self.object:set_sprite({x=0, y=0}, 4, 1.0, false)
end,
})
+
+minetest.register_entity("testentities:nametag", {
+ initial_properties = {
+ visual = "sprite",
+ textures = { "testentities_sprite.png" },
+ },
+
+ on_activate = function(self, staticdata)
+ if staticdata ~= "" then
+ self.color = minetest.deserialize(staticdata).color
+ else
+ self.color = {
+ r = math.random(0, 255),
+ g = math.random(0, 255),
+ b = math.random(0, 255),
+ }
+ end
+
+ assert(self.color)
+ self.object:set_properties({
+ nametag = tostring(math.random(1000, 10000)),
+ nametag_color = self.color,
+ })
+ end,
+
+ get_staticdata = function(self)
+ return minetest.serialize({ color = self.color })
+ end,
+})