mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Add nametag background setting and object property (#10937)
This commit is contained in:
parent
a8f6befd39
commit
f85e9ab925
17 changed files with 254 additions and 58 deletions
|
@ -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,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue