-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |