Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth authored Mar 7, 2021
1 parent b052722 commit f583eb8
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
69 changes: 69 additions & 0 deletions autochannel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
AutoChannel = {VERSION = {major=1,minor=0,patch=0}}

local WARBAND = "/wb"
local PARTY = "/p"
local SCPARTY = "/sp"
local SCENARIO = "/sc"
local SAY = "/s"

local function getSmartPartyChannel()
local groupData = GetGroupData()
for k,v in pairs(groupData) do
if v and v.name and v.name ~= L"" then
return PARTY
end
end
return SAY
end

local function getSmartBandChannel()
if IsWarBandActive() then
return WARBAND
end
return GetSmartPartyChannel()
end

local function send(channel, message, allowSay)
if channel == SAY and not allowSay then
return
end
if (GameData.Player.isInScenario) then
if (channel == PARTY) then
channel = SCPARTY
elseif (channel == WARBAND) then
channel = SCENARIO
end
end

message = channel.." "..message
SendChatText(towstring(message), L"")
end

function AutoChannel.sendChatBand(phrase)
local channel = getSmartBandChannel()
send(channel, phrase, false)
end

function AutoChannel.sendChatParty(phrase)
local channel = getSmartPartyChannel()
send(channel, phrase, false)
end

function AutoChannel.sendChatBandSay(phrase)
local channel = getSmartBandChannel()
send(channel, phrase, true)
end

function AutoChannel.sendChatPartySay(phrase)
local channel = getSmartPartyChannel()
send(channel, phrase, true)
end

function AutoChannel.Initialize()
LibSlash.RegisterSlashCmd("acp", AutoChannel.sendChatParty)
LibSlash.RegisterSlashCmd("acb", AutoChannel.sendChatBand)
LibSlash.RegisterSlashCmd("acps", AutoChannel.sendChatPartySay)
LibSlash.RegisterSlashCmd("acbs", AutoChannel.sendChatBandSay)
end


21 changes: 21 additions & 0 deletions autochannel.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ModuleFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UiMod name="AutoChannel" version="1.0.0" date="2021-03-06" >
<Author name="Idrinth"/>
<Description text="Automatically picks a channel from party, warband, scenario and scenariogroup" />
<VersionSettings gameVersion="1.4.8" />
<Dependencies>
<Dependency name="EA_ChatWindow" />
<Dependency name="LibSlash" />
</Dependencies>
<Files>
<File name="autochannel.lua" />
</Files>
<SavedVariables/>
<OnInitialize>
<CallFunction name="AutoChannel.Initialize" />
</OnInitialize>
<OnUpdate/>
<OnShutdown/>
</UiMod>
</ModuleFile>

0 comments on commit f583eb8

Please sign in to comment.