mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
improved error mitigation
This commit is contained in:
parent
0beb2b1077
commit
a9c8560136
1 changed files with 30 additions and 21 deletions
51
text.lua
51
text.lua
|
@ -234,33 +234,42 @@ function airutils.convert_text_to_texture(text, default_color, horizontal_aligme
|
||||||
text = text or ""
|
text = text or ""
|
||||||
default_color = default_color or 0
|
default_color = default_color or 0
|
||||||
horizontal_aligment = horizontal_aligment or 3
|
horizontal_aligment = horizontal_aligment or 3
|
||||||
local font_size
|
if not signs_lib then return "" end
|
||||||
local line_width
|
local font_size = 16
|
||||||
local line_height
|
local line_width = 1
|
||||||
local char_width
|
local line_height = 1
|
||||||
local colorbgw
|
local char_width = 1
|
||||||
local chars_per_line
|
local colorbgw = ""
|
||||||
local widemult
|
local chars_per_line = 21
|
||||||
|
local widemult = 0.5
|
||||||
local count = 0
|
local count = 0
|
||||||
--text = string.sub(text,1,max_lenght)
|
--text = string.sub(text,1,max_lenght)
|
||||||
text, count = clamp_characters(text, max_lenght)
|
text, count = clamp_characters(text, max_lenght)
|
||||||
|
|
||||||
if count <= 10 then
|
if count <= 10 then
|
||||||
widemult = 0.75
|
if signs_lib.avgwidth32 then
|
||||||
font_size = 32
|
widemult = 0.75
|
||||||
chars_per_line = 10
|
font_size = 32
|
||||||
line_width = math.floor(signs_lib.avgwidth32 * chars_per_line) * (horizontal_aligment * widemult)
|
chars_per_line = 10
|
||||||
line_height = signs_lib.lineheight32
|
line_width = math.floor(signs_lib.avgwidth32 * chars_per_line) * (horizontal_aligment * widemult)
|
||||||
char_width = signs_lib.charwidth32
|
line_height = signs_lib.lineheight32
|
||||||
colorbgw = signs_lib.colorbgw32
|
char_width = signs_lib.charwidth32
|
||||||
|
colorbgw = signs_lib.colorbgw32
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
else
|
else
|
||||||
widemult = 0.5
|
if signs_lib.avgwidth16 then
|
||||||
font_size = 16
|
widemult = 0.5
|
||||||
chars_per_line = 21
|
font_size = 16
|
||||||
line_width = math.floor(signs_lib.avgwidth16 * chars_per_line) * (horizontal_aligment * widemult)
|
chars_per_line = 21
|
||||||
line_height = signs_lib.lineheight16
|
line_width = math.floor(signs_lib.avgwidth16 * chars_per_line) * (horizontal_aligment * widemult)
|
||||||
char_width = signs_lib.charwidth16
|
line_height = signs_lib.lineheight16
|
||||||
colorbgw = signs_lib.colorbgw16
|
char_width = signs_lib.charwidth16
|
||||||
|
colorbgw = signs_lib.colorbgw16
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local texture = { ("[combine:%dx%d"):format(line_width, line_height) }
|
local texture = { ("[combine:%dx%d"):format(line_width, line_height) }
|
||||||
|
|
Loading…
Add table
Reference in a new issue