John Posted July 5, 2024 Share Posted July 5, 2024 Для моей задачи нужно генерировать строку из заданного алфавита. Пишу код в engine. Пока не получилось, покажите пример. Quote Link to comment Share on other sites More sharing options...
TechnoViking Posted July 5, 2024 Share Posted July 5, 2024 Для этого можно написать функцию на чистом lua: local charset = "abcdefghijklmnopqrstuvwxyz1234567890" function string.random(length) if length > 0 then return string.random(length - 1) .. charset:sub(math.random(1, #charset), 1) else return "" end end print (string.random(10)) В engine есть встроенная функция random_string, которая входит в пакет utils. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.