From 59f7fb9fd71ce47ea0daf00a30dae8b604bdcb5e Mon Sep 17 00:00:00 2001 From: Wil <63251107+wilyt1@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:55:58 -0400 Subject: [PATCH] Refactor rand Command to Use Random Class --- Cmdr/BuiltInCommands/Utility/rand.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Cmdr/BuiltInCommands/Utility/rand.lua b/Cmdr/BuiltInCommands/Utility/rand.lua index 3f77f0b0..e039d98d 100644 --- a/Cmdr/BuiltInCommands/Utility/rand.lua +++ b/Cmdr/BuiltInCommands/Utility/rand.lua @@ -1,3 +1,5 @@ +local generator = Random.new() + return { Name = "rand", Aliases = {}, @@ -17,7 +19,11 @@ return { }, }, - ClientRun = function(_, min, max) - return tostring(max and math.random(min, max) or math.random(min)) + ClientRun = function(_, firstNumber, secondNumber) + return tostring( + if secondNumber + then generator:NextInteger(firstNumber, secondNumber) + else generator:NextInteger(1, firstNumber) + ) end, }