mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
fix: missing Random:seed method
This commit is contained in:
parent
1f3b7f828d
commit
1350910d28
3 changed files with 21 additions and 6 deletions
|
|
@ -674,6 +674,9 @@ function __vc_create_random_methods(random_methods)
|
|||
local buffer = nil
|
||||
local buffer_size = 64
|
||||
|
||||
local seed_func = random_methods.seed
|
||||
local random_func = random_methods.random
|
||||
|
||||
function random_methods:bytes(n)
|
||||
local bytes = Bytearray(n)
|
||||
for i=1,n do
|
||||
|
|
@ -682,9 +685,14 @@ function __vc_create_random_methods(random_methods)
|
|||
return bytes
|
||||
end
|
||||
|
||||
function random_methods:seed(x)
|
||||
seed_func(self, x)
|
||||
buffer = nil
|
||||
end
|
||||
|
||||
function random_methods:random(a, b)
|
||||
if not buffer or index > #buffer then
|
||||
buffer = self:generate(buffer_size)
|
||||
buffer = random_func(self, buffer_size)
|
||||
index = 1
|
||||
end
|
||||
local value = buffer[index]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue