Compare commits

..

No commits in common. "88f09f4fe48c26884a2e10613c0efd10c70203ee" and "865404ffb75d5761fda5c8ac6863fe5cc86c89f6" have entirely different histories.

2 changed files with 17 additions and 26 deletions

View file

@ -2,7 +2,7 @@
## Title: AltSystem ## Title: AltSystem
## Notes: Enhances RP gameplay with a custom rolling system ## Notes: Enhances RP gameplay with a custom rolling system
## Author: Rukira ## Author: Rukira
## Version: 0.4 ## Version: 0.3
## Dependencies: totalRP3, totalRP3_Extended ## Dependencies: totalRP3, totalRP3_Extended
## SavedVariables: AltSystemDB ## SavedVariables: AltSystemDB

View file

@ -26,11 +26,17 @@ local function BuildModifierString(modifiers)
return table.concat(parts, " ") return table.concat(parts, " ")
end end
-- Send a message to the given channel. -- Send a message to the given channel, handling EMOTE specially
-- Note: EMOTE channel uses SendChatMessage like all others. The WoW API -- to avoid the message being redirected to raid chat when in a raid group.
-- SendChatMessage(msg, "EMOTE") sends a proper /e emote from any context,
-- unlike RunMacroText which is a protected function requiring a hardware event.
local function SendToChannel(msg, channel) local function SendToChannel(msg, channel)
if channel == "EMOTE" then
local editBox = ChatFrame1 and ChatFrame1.editBox or ChatFrame1EditBox
if editBox then
ChatFrame_OpenChat("/e " .. msg, ChatFrame1)
ChatEdit_SendText(editBox)
end
return
end
SendChatMessage(msg, channel) SendChatMessage(msg, channel)
end end
@ -41,24 +47,15 @@ local function AnnounceRoll(rollValue, modifiers, total)
local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex] local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex]
if not channelDef then return end if not channelDef then return end
local isEmote = channelDef.channel == "EMOTE" local name = GetCharacterName()
local modStr = BuildModifierString(modifiers) local modStr = BuildModifierString(modifiers)
local msg local msg
if isEmote then
if modStr ~= "" then
msg = "rolled " .. rollValue .. " " .. modStr .. " = " .. total
else
msg = "rolled " .. rollValue .. " = " .. total
end
else
local name = GetCharacterName()
if modStr ~= "" then if modStr ~= "" then
msg = name .. " rolled " .. rollValue .. " " .. modStr .. " = " .. total msg = name .. " rolled " .. rollValue .. " " .. modStr .. " = " .. total
else else
msg = name .. " rolled " .. rollValue .. " = " .. total msg = name .. " rolled " .. rollValue .. " = " .. total
end end
end
SendToChannel(msg, channelDef.channel) SendToChannel(msg, channelDef.channel)
end end
@ -97,10 +94,7 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
if AltSystem.State.announceEnabled then if AltSystem.State.announceEnabled then
local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex] local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex]
if channelDef then if channelDef then
local critMsg = channelDef.channel == "EMOTE" SendToChannel(GetCharacterName() .. " rolled a Critical Failure!", channelDef.channel)
and "rolled a Critical Failure!"
or (GetCharacterName() .. " rolled a Critical Failure!")
SendToChannel(critMsg, channelDef.channel)
end end
end end
return return
@ -111,10 +105,7 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
if AltSystem.State.announceEnabled then if AltSystem.State.announceEnabled then
local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex] local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex]
if channelDef then if channelDef then
local critMsg = channelDef.channel == "EMOTE" SendToChannel(GetCharacterName() .. " rolled a Critical Success!", channelDef.channel)
and "rolled a Critical Success!"
or (GetCharacterName() .. " rolled a Critical Success!")
SendToChannel(critMsg, channelDef.channel)
end end
end end
return return