From f85e9ab9254e2ae4ac13170f9edea00fb8d931a2 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 17 Feb 2021 19:51:28 +0000 Subject: Add nametag background setting and object property (#10937) --- games/devtest/mods/testentities/visuals.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'games/devtest') diff --git a/games/devtest/mods/testentities/visuals.lua b/games/devtest/mods/testentities/visuals.lua index e3b758329..e382ec44c 100644 --- a/games/devtest/mods/testentities/visuals.lua +++ b/games/devtest/mods/testentities/visuals.lua @@ -103,23 +103,35 @@ minetest.register_entity("testentities:nametag", { on_activate = function(self, staticdata) if staticdata ~= "" then - self.color = minetest.deserialize(staticdata).color + local data = minetest.deserialize(staticdata) + self.color = data.color + self.bgcolor = data.bgcolor else self.color = { r = math.random(0, 255), g = math.random(0, 255), b = math.random(0, 255), } + + if math.random(0, 10) > 5 then + self.bgcolor = { + r = math.random(0, 255), + g = math.random(0, 255), + b = math.random(0, 255), + a = math.random(0, 255), + } + end end assert(self.color) self.object:set_properties({ nametag = tostring(math.random(1000, 10000)), nametag_color = self.color, + nametag_bgcolor = self.bgcolor, }) end, get_staticdata = function(self) - return minetest.serialize({ color = self.color }) + return minetest.serialize({ color = self.color, bgcolor = self.bgcolor }) end, }) -- cgit v1.2.3