From 5b69e248e4a69d6c9521213d499cb441499f49d8 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 6 Dec 2024 18:45:01 +0100 Subject: [PATCH] Implement channeljoiner... to join channels --- FreshShit/ChannelJoiner/event.lua | 4 +++ FreshShit/ChannelJoiner/init.lua | 42 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 FreshShit/ChannelJoiner/event.lua create mode 100644 FreshShit/ChannelJoiner/init.lua diff --git a/FreshShit/ChannelJoiner/event.lua b/FreshShit/ChannelJoiner/event.lua new file mode 100644 index 0000000..2016f8e --- /dev/null +++ b/FreshShit/ChannelJoiner/event.lua @@ -0,0 +1,4 @@ +-- PLAYER_ENTERING_WORLD +function() + aura_env.JoinChannels() +end \ No newline at end of file diff --git a/FreshShit/ChannelJoiner/init.lua b/FreshShit/ChannelJoiner/init.lua new file mode 100644 index 0000000..50e3469 --- /dev/null +++ b/FreshShit/ChannelJoiner/init.lua @@ -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 \ No newline at end of file