Implement channeljoiner... to join channels

This commit is contained in:
2024-12-06 18:45:01 +01:00
parent 4ab2cd0eb9
commit 5b69e248e4
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
-- PLAYER_ENTERING_WORLD
function()
aura_env.JoinChannels()
end

View File

@@ -0,0 +1,42 @@
---@type string[]
local channelNames = {}
---@type string[]
local channelPasswords = {}
---@type string|nil
local err
---@param input string
---@param deliminer string
---@return string[], string|nil
local function StrSplit(input, deliminer)
if not deliminer then return {}, "deliminer is nil" end
if not input then return {}, "input is nil" end
local parts = {}
for part in string.gmatch(input, "([^" .. deliminer .. "]+)") do
table.insert(parts, strtrim(part))
end
return parts, nil
end
channelNames, err = StrSplit(aura_env.config.channels, ",")
if err then
print(string.format("Error splitting channels: %s", err))
return
end
channelPasswords, err = StrSplit(aura_env.config.channelPasswords, ",")
if err then
print(string.format("Error splitting channel passwords: %s", err))
return
end
aura_env.JoinChannels = function()
for i, channelName in ipairs(channelNames) do
channelName = strtrim(channelName)
local password = nil
if i <= #channelPasswords then
password = strtrim(channelPasswords[i])
end
JoinPermanentChannel(channelName, password)
end
end