12.01.2024, 08:51
You can simply use string.format:
For converting number to a string you can either use Custom values or a table instead of multiple IFs:
Code:
val = 1
str = string.format('%02d', val) -- pad with 0 up to 2 chars in width
log(str) -- will log "01"
For converting number to a string you can either use Custom values or a table instead of multiple IFs:
Code:
values = {
[1] = 'Value 1',
[2] = 'Value 2',
[3] = 'Value 3',
}
val = values[ 2 ]
log(val) -- will log "Value 2"