Merge branch 'main' into headless-mode

This commit is contained in:
MihailRis 2024-12-21 10:58:41 +03:00
commit 79f5ffc463
2 changed files with 41 additions and 0 deletions

View File

@ -46,6 +46,13 @@ table.remove_value(t: table, x: object)
Удаляет элемент **x** из **t**.
```lua
table.shuffle(t: table) -> table
```
Перемешивает значения в таблице.
```lua
table.tostring(t: table) -> string
```
@ -146,6 +153,18 @@ math.rand(low, high)
Возвращает случайное дробное число в диапазоне от **low** до **high**.
```lua
math.normalize(num: number, [опционально] conf: num) -> number
```
Возвращает нормализованное значение num относительно conf.
```lua
math.round(num: number, [опционально] places: num) -> number
```
Возвращает округлённое значение num до указанного количества знаков после запятой places.
## Дополнительные глобальные функции
В этом же скрипте также определены и другие глобальные функции которые доступны для использования. Ниже их список

View File

@ -51,6 +51,19 @@ function math.rand(low, high)
return low + (high - low) * math.random()
end
function math.normalize(num, conf)
conf = conf or 1
return (num / conf) % 1
end
function math.round(num, places)
places = places or 0
local mult = 10 ^ places
return math.floor(num * mult + 0.5) / mult
end
----------------------------------------------
function table.copy(t)
@ -91,6 +104,15 @@ function table.random(t)
return t[math.random(1, #t)]
end
function table.shuffle(t)
for i = #t, 2, -1 do
local j = math.random(i)
t[i], t[j] = t[j], t[i]
end
return t
end
----------------------------------------------
local pattern_escape_replacements = {