Implement channeljoiner... to join channels
This commit is contained in:
4
FreshShit/ChannelJoiner/event.lua
Normal file
4
FreshShit/ChannelJoiner/event.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
-- PLAYER_ENTERING_WORLD
|
||||
function()
|
||||
aura_env.JoinChannels()
|
||||
end
|
42
FreshShit/ChannelJoiner/init.lua
Normal file
42
FreshShit/ChannelJoiner/init.lua
Normal 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
|
Reference in New Issue
Block a user