Thread Tools Display Modes
02-27-09, 11:47 PM   #1
Zelik
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 7
Opening Trade Windows With CastSpellByName()

An addon that I am making requires trade windows to be opened/closed automatically.

While CastSpellByName() is a protected function, the game does not seem to block calling it to open a trade window.

If I type in "/run CastSpellByName("Tailoring")", than it works fine. However, I cannot get a trade window to be opened as the result of an event, which is what I'd like.

Is this intended? Is there a way to work around it?
  Reply With Quote
02-28-09, 05:43 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
This is intended. CastSpellByName() requires a hardware event.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
03-01-09, 09:37 AM   #3
ZikO
An Aku'mai Servant
Join Date: Jun 2008
Posts: 36
Originally Posted by Seerah View Post
This is intended. CastSpellByName() requires a hardware event.
What are those hardware events and do all protected API functions require hardware events?

Thanks
  Reply With Quote
03-01-09, 11:38 AM   #4
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by ZikO View Post
What are those hardware events and do all protected API functions require hardware events?

Thanks
It means the UI can't cast a spell unless it is invoked by a keyboard binding or button press. Before 2.0, when CastSpellByName() and the movement functions were available to addon code, you could have written a real bot in Lua if it weren't for that fact.

Not all protected functions require a hardware event, no.
  Reply With Quote
03-01-09, 01:05 PM   #5
ZikO
An Aku'mai Servant
Join Date: Jun 2008
Posts: 36
thanks for that Akryn, it sounds reasonable. Can I ask you one more question? What are protected functions?

Sorry if I ask these questions post by post. This is the way I learn all this stuff :P

Best regards.
  Reply With Quote
03-01-09, 03:40 PM   #6
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
A protected function is one that cannot be called by insecure code (i.e., you, or code you tainted). That being said, the fact that you are able to run CastSpellByName("Tailoring") implies that it is not protected and rather a sub-call of it is protected, but the fact of the matter remains that you can't use CastSpellByName() to cast spells directly.

Simply put, a protected function is a function that you cannot use directly.
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Opening Trade Windows With CastSpellByName()


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