position markers: colourise numbers

This commit is contained in:
Starbeamrainbowlabs 2022-09-20 03:21:55 +01:00
parent 3fa6dbefcf
commit 7f2be74580
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2

@ -66,20 +66,41 @@ local function delete(entity)
}) })
end end
local number_colours = {
"#FF0000",
"#FF8800",
"#FFFF00",
"#88FF00",
"#00FF00",
"#00FF88",
"#00FFFF",
"#0088FF",
"#0000FF",
"#8800ff",
"#FF00ff",
"#FF0088"
}
local function set_number(entity, display_number) 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 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 if display_number < 100 then
local number_right = display_number % 10 local number_right = display_number % 10
local number_left = (display_number - number_right) / 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" texture_name = texture_name.."^worldeditadditions_r"..number_right..".png"
print("DEBUG:set_number number_left", number_left, "number_right", number_right) print("DEBUG:set_number number_left", number_left, "number_right", number_right)
end
texture_name = "("..texture_name..")^[opacity:220" 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
print("DEBUG:set_number texture_name", texture_name) print("DEBUG:set_number texture_name", texture_name)