Randomize a little more

This commit is contained in:
2024-12-15 01:42:09 +01:00
parent b959336050
commit 6b3d584f98

View File

@@ -1,9 +1,12 @@
local addonname, data = ... local addonname, data = ...
---@cast addonname string ---@cast addonname string
local channelNameLength = 8 local channelNameLength = 8
local messageLength = 32 local messageLengthLowerBound = 12
local messageLengthUpperBound = 47
local lowerBound = 53 local lowerBound = 53
local upperBound = 77 local upperBound = 77
local asciiStart = 97
local asciiEnd = 122
local function GetChannelId(channelName) local function GetChannelId(channelName)
local channels = { GetChannelList() } local channels = { GetChannelList() }
@@ -17,16 +20,17 @@ local function GetChannelId(channelName)
end end
local function GenerateString(length) local function GenerateString(length)
print(string.format("Generating string of length %d", length))
local string = "" local string = ""
for i = 1, length do for i = 1, length do
string = string .. string.char(math.random(97, 122)) string = string .. string.char(math.random(asciiStart, asciiEnd))
end end
return string return string
end end
local channelName = GenerateString(channelNameLength) local channelName = GenerateString(channelNameLength)
local function Yap() local function Yap()
local message = GenerateString(messageLength) local message = GenerateString(math.random(messageLengthLowerBound, messageLengthUpperBound))
print(string.format("YAPPING %s", tostring(message))) print(string.format("YAPPING %s", tostring(message)))
local channelId = GetChannelId(channelName) local channelId = GetChannelId(channelName)
@@ -44,9 +48,7 @@ end
local function init() local function init()
JoinTemporaryChannel(channelName) JoinTemporaryChannel(channelName)
print(string.format("Yapper joined %s", tostring(channelName))) print(string.format("Yapper joined %s", tostring(channelName)))
local delay = math.random(lowerBound, upperBound) Yap()
print(string.format("Yapper yapping in %d seconds", delay))
C_Timer.After(delay, Yap)
end end
local loadedFrame = CreateFrame("Frame") local loadedFrame = CreateFrame("Frame")