mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-23 22:22:23 +01:00
position markers: colourise numbers
This commit is contained in:
parent
3fa6dbefcf
commit
7f2be74580
@ -66,20 +66,41 @@ local function delete(entity)
|
||||
})
|
||||
end
|
||||
|
||||
local number_colours = {
|
||||
"#FF0000",
|
||||
"#FF8800",
|
||||
"#FFFF00",
|
||||
"#88FF00",
|
||||
"#00FF00",
|
||||
"#00FF88",
|
||||
"#00FFFF",
|
||||
"#0088FF",
|
||||
"#0000FF",
|
||||
"#8800ff",
|
||||
"#FF00ff",
|
||||
"#FF0088"
|
||||
}
|
||||
|
||||
local function set_number(entity, display_number)
|
||||
if type(display_number) ~= "number" then return false, "Error: The 'display_number' property must be of type number, but received value of unexpected type '"..type(display_number).."'." end
|
||||
|
||||
local texture_name = "worldeditadditions_bg.png"
|
||||
local texture_name = ""
|
||||
|
||||
if display_number < 100 then
|
||||
local number_right = display_number % 10
|
||||
local number_left = (display_number - number_right) / 10
|
||||
texture_name = texture_name.."^worldeditadditions_l"..number_left..".png"
|
||||
texture_name = texture_name.."worldeditadditions_l"..number_left..".png"
|
||||
texture_name = texture_name.."^worldeditadditions_r"..number_right..".png"
|
||||
print("DEBUG:set_number number_left", number_left, "number_right", number_right)
|
||||
|
||||
local colour_id = (display_number % 12) + 1 -- Lua starts from 1, not 0 :-/
|
||||
texture_name = "("..texture_name..")^[colorize:"..number_colours[colour_id]..":255"
|
||||
end
|
||||
if #texture_name > 0 then
|
||||
texture_name = "worldeditadditions_bg.png^("..texture_name..")"
|
||||
else
|
||||
texture_name = "worldeditadditions_bg.png"
|
||||
end
|
||||
|
||||
texture_name = "("..texture_name..")^[opacity:220"
|
||||
|
||||
print("DEBUG:set_number texture_name", texture_name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user