Quantcast SendChatMessage help - WoWInterface
Thread Tools Display Modes
05-03-11, 05:39 AM   #1
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 128
Exclamation SendChatMessage help

HEY ALL, I have seen this 1 time but now a few others have, on my autoress code you get an error, it seems to be to do with the SendChatMessage when in combat, a message will say cant till xamount of time.

Code:
1x SendChatMessage(): Invalid escape code in chat message:
<in C code>: ?
<in C code>: in function `SendChatMessage'
wIn1-5.0\wIn1.lua:131: in function `?'
wIn1-5.0\wIn1.lua:617: in function <wIn1\wIn1.lua:616>

Locals:
(*temporary) = "Thanks for the rez! I still have 14 |4second:seconds; until I can accept it."
(*temporary) = "WHISPER"
(*temporary) = nil
(*temporary) = "nameremoved"
the error here seems to be todo with the event hand, of what is not near the main code

Code:
	local frame = CreateFrame('Frame')
	frame:Hide()

	for event, handler in pairs(eventHandlers) do
		frame[event] = handler
		frame:RegisterEvent(event)
		eventHandlers[event] = nil
	end

	frame:SetScript('OnEvent', function(self, event, ...)
		self[event](...)
	end)
but the error it self


Code:
	eventHandlers['RESURRECT_REQUEST'] = function(name)
		if not (UnitAffectingCombat('player') or UnitAffectingCombat(name)) then
			local delay = GetCorpseRecoveryDelay()
			if delay == 0 then
				AcceptResurrect()
				DoEmote('thank', name)
			else
				SendChatMessage(("Thanks for the rez! I still have %d |4second:seconds; until I can accept it."):format(delay), 'WHISPER', nil, name)
			end
		end
	end
anyhelp would be great, thanks
__________________
wMmap :: Is a lightweight Minimap, with a sleek look & custom imagery.
wIn1 :: In one addon. and is very lightweight & simple to use.
wChat :: Is a lightweight chat mod.
wBroker :: Is A simple broker add-on.
wPetXPBar :: Is A simple lightweight Pet XP Bar.
wBuffs :: Is A simple Buffs Bar.
  Reply With Quote
05-03-11, 05:55 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 761
"|" is a special character, not sure what you need it for in your string
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
05-03-11, 06:30 AM   #3
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 128
Originally Posted by Rilgamon View Post
"|" is a special character, not sure what you need it for in your string
ahh maybe like %d 4second:seconds;

im not sure why that is there. im sure i read something about use it.
__________________
wMmap :: Is a lightweight Minimap, with a sleek look & custom imagery.
wIn1 :: In one addon. and is very lightweight & simple to use.
wChat :: Is a lightweight chat mod.
wBroker :: Is A simple broker add-on.
wPetXPBar :: Is A simple lightweight Pet XP Bar.
wBuffs :: Is A simple Buffs Bar.
  Reply With Quote
05-03-11, 06:35 AM   #4
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 926
I also had problems with using grammar UI escape sequences in SendChatMessage, for the same pipe character "|" reason that Rilgamon just explained

Dridzt has posted a workaround for setting and grabbing the formatted text from a frame
Code:
local b = CreateFrame("Button")
Code:
	eventHandlers['RESURRECT_REQUEST'] = function(name)
		if not (UnitAffectingCombat('player') or UnitAffectingCombat(name)) then
			local delay = GetCorpseRecoveryDelay()
			if delay == 0 then
				AcceptResurrect()
				DoEmote('thank', name)
			else
				local formattedText = b:GetText(b:SetFormattedText("%d |4second:seconds;", delay))
				SendChatMessage("Thanks for the rez! I still have "..formattedText.." until I can accept it.", 'WHISPER', nil, name)
			end
		end
	end

Last edited by Ketho : 05-03-11 at 07:12 AM. Reason: added that trailing semicolon ";" to the UI escape sequence although I dont know what it's actually for
  Reply With Quote
05-03-11, 07:01 AM   #5
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 128
oh nice one. i will try this out. if i put the local b = CreateFrame("Button")
in with the code. it should work out right.

Code:
	eventHandlers['RESURRECT_REQUEST'] = function(name)
		if not (UnitAffectingCombat('player') or UnitAffectingCombat(name)) then
			local delay = GetCorpseRecoveryDelay()
			if delay == 0 then
				AcceptResurrect()
				DoEmote('thank', name)
			else
                                local b = CreateFrame("Button")
				local formattedText = b:GetText(b:SetFormattedText("%d |4second:seconds", delay))
				SendChatMessage("Thanks for the rez! I still have "..formattedText.." until I can accept it.", 'WHISPER', nil, name)
			end
		end
	end
__________________
wMmap :: Is a lightweight Minimap, with a sleek look & custom imagery.
wIn1 :: In one addon. and is very lightweight & simple to use.
wChat :: Is a lightweight chat mod.
wBroker :: Is A simple broker add-on.
wPetXPBar :: Is A simple lightweight Pet XP Bar.
wBuffs :: Is A simple Buffs Bar.
  Reply With Quote
05-03-11, 07:24 AM   #6
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 792
I do have one question, why use that method?

All it does is return "%d seconds" and all that again does is put the GetCorpseRecoveryDelay() value (number) so it is "0 seconds", wouldn't it just be easier to do this?

Code:
eventHandlers['RESURRECT_REQUEST'] = function(name)
  if UnitAffectingCombat("player") or UnitAffectingCombat(name) then return end

  local delay = GetCorpseRecoveryDelay()
  if delay == 0 then
    AcceptResurrect()
    DoEmote("thank", name)
  else
    SendChatMessage("Thanks for the rez! I still have "..delay.." seconds until I can accept it.", "WHISPER", nil, name)
  end
end
Maybe I am missing something.
  Reply With Quote
05-03-11, 07:42 AM   #7
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 128
Thumbs up

Originally Posted by Vladinator View Post
I do have one question, why use that method?

All it does is return "%d seconds" and all that again does is put the GetCorpseRecoveryDelay() value (number) so it is "0 seconds", wouldn't it just be easier to do this?

Code:
eventHandlers['RESURRECT_REQUEST'] = function(name)
  if UnitAffectingCombat("player") or UnitAffectingCombat(name) then return end

  local delay = GetCorpseRecoveryDelay()
  if delay == 0 then
    AcceptResurrect()
    DoEmote("thank", name)
  else
    SendChatMessage("Thanks for the rez! I still have "..delay.." seconds until I can accept it.", "WHISPER", nil, name)
  end
end
Maybe I am missing something.
I see what you mean. but unsure, as i have not used that way. i will give it ago. thanks for the tip.
__________________
wMmap :: Is a lightweight Minimap, with a sleek look & custom imagery.
wIn1 :: In one addon. and is very lightweight & simple to use.
wChat :: Is a lightweight chat mod.
wBroker :: Is A simple broker add-on.
wPetXPBar :: Is A simple lightweight Pet XP Bar.
wBuffs :: Is A simple Buffs Bar.
  Reply With Quote
05-03-11, 07:54 AM   #8
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 174
Because

"%d |4second:seconds;"

will automatically select "second" or "seconds" depending on the number in %d.
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
  Reply With Quote
05-03-11, 07:59 AM   #9
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 792
I did not know that Xinhuan, thanks!

"|#A:B;" I guess where A is single form and B is plural form. What does the "4" mean? But what does # do? Is there some sort of lexicon over the type of "|...;" you can create?

Trying to figure if it's something to WoW LUA only or if regular LUA also supports such syntaxes in strings.
  Reply With Quote
05-03-11, 08:06 AM   #10
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
|1 is used is to choose the word if the preceding number is a 1 or 0

|1steve;frank; will return steve for any number ending in 1 or 0 (0,1, 10,11, 20,21...)

|2 is really for french i think, will change de to d' and remove the space if the next word starts with a vowel

|3 is for German,

and |4 is singular/plural detector

|4second:seconds; for proper word choosing
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
05-04-11, 11:14 AM   #11
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 174
Originally Posted by Vladinator View Post
Trying to figure if it's something to WoW LUA only or if regular LUA also supports such syntaxes in strings.
Xubera has them. They are WoW specific escapes.
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SendChatMessage help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off