Thread Tools Display Modes
12-04-14, 12:55 AM   #1
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
C_Timer.After usage

Code:
if message:match("call1") then
			C_Timer.After(7, SendChatMessage(string.gsub(message, "call1", "call2"), "SAY"))
			C_Timer.After(15, SendChatMessage(string.gsub(message, "call1", "call3"), "SAY"))
end
and Bugger throws me:
1x SoAData\SoAData-1.3.lua:18: Usage: C_Timer.After(seconds, func)
[C]:: in function 'After'
SoAData\SoAData-1.3.lua:18: in function <SoAData\SoAData.lua:9

In that way i had used before http://www.wowwiki.com/USERAPI_wait (and its still working, just wondering how to use that new C_Timer.After)

So, i messed some commas or brackets, or just using it all wrong?
Attached Files
File Type: txt mycode.txt (1.0 KB, 268 views)
  Reply With Quote
12-04-14, 01:34 AM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Your current code is calling SendChatMessage as soon as it it's executed and passing the return value (either nothing or nil) to C_Timer.After.

You need to wrap those SendChatMessage calls in functions and pass the function to C_Timer.After:
lua Code:
  1. if message:match("call1") then
  2.     C_Timer.After(7, function() SendChatMessage(string.gsub(message, "call1", "call2"), "SAY") end)
  3.     C_Timer.After(15, function() SendChatMessage(string.gsub(message, "call1", "call3"), "SAY") end)
  4. end
  Reply With Quote
12-04-14, 04:13 AM   #3
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
thanks , was thinking SendChatMessage is function themselves
  Reply With Quote
12-04-14, 05:01 AM   #4
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Originally Posted by Mazzop View Post
thanks , was thinking SendChatMessage is function themselves
SendChatMessage is a function, but you were calling it immediately instead of passing a callback function that calls SendChatMessage.
  Reply With Quote
12-04-14, 05:31 AM   #5
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Mazzop View Post
thanks , was thinking SendChatMessage is function themselves
SendChatMessage is a function, like this:
Code:
function SendChatMessage(...)
end
But this is a function call:
Code:
SendChatMessage("hi")
Code:
/dump math.floor
=function

but
Code:
/dump math.floor(1.5)
= 1
__________________
Grab your sword and fight the Horde!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » C_Timer.After usage


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