diff options
author | rubenwardy <rw@rubenwardy.com> | 2021-02-17 19:51:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-17 19:51:28 +0000 |
commit | f85e9ab9254e2ae4ac13170f9edea00fb8d931a2 (patch) | |
tree | 43fa19520c7f744f798de0ed8bcbb8e01c82e327 /games | |
parent | a8f6befd398cb8f962f3bb1fab092d6355bfe015 (diff) | |
download | minetest-f85e9ab9254e2ae4ac13170f9edea00fb8d931a2.tar.gz minetest-f85e9ab9254e2ae4ac13170f9edea00fb8d931a2.tar.bz2 minetest-f85e9ab9254e2ae4ac13170f9edea00fb8d931a2.zip |
Add nametag background setting and object property (#10937)
Diffstat (limited to 'games')
-rw-r--r-- | games/devtest/mods/testentities/visuals.lua | 16 |
1 files changed, 14 insertions, 2 deletions
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, }) |