Thread Tools Display Modes
08-04-07, 12:44 AM   #1
romkatv
A Deviate Faerie Dragon
Join Date: May 2006
Posts: 15
IsPlayerMoving, IsPlayerTyping implementation

Fellow gurus,

I need 2 functions for my addon.

1. IsPlayerMoving. Should return true iif player is moving in any direction. If player just turning left or right without movement, then function should return false. Generally speaking, if player tries to cast non-instant-cast spell and it says "can't do that while moving", then IsPlayerMoving should return true.

2. IsPlayerTyping. Should return true iif player's keyboard input goes to chat window. For example, if player pressed on her keyboard "enter" "h" "e" "l" and didn't press "enter" again, then function should return true because next key pressed will affect chat window and won't affect actions bars, etc.

Can anyone help me with this functions implementation? Any pointers?

Regards,
Roman.
  Reply With Quote
08-04-07, 03:11 AM   #2
Tekkub
A Molten Giant
 
Tekkub's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 960
Moving: two ways...
Watch the player's location on the map with an onupdate. Works wonderfully, unless they are in an instance.
Hook all the movement keys... could be very expensive being as they'd have to be secure hooks, which are expensive in the first place... and movement gets called A LOT

Typing... simplest route I can think of is check to see if the edit box is visible
  Reply With Quote
08-04-07, 03:58 AM   #3
tardmrr
Lua Ninja
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 133
ChatFrameEditBox:HasFocus()
  Reply With Quote
08-04-07, 04:24 AM   #4
romkatv
A Deviate Faerie Dragon
Join Date: May 2006
Posts: 15
Thanks a lot for your answers. I've implemented both functions using your tips.

One more question. How can I determine whether player's character is sitting or not?

Roman.
  Reply With Quote
08-04-07, 01:33 PM   #5
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
Originally Posted by romkatv
Thanks a lot for your answers. I've implemented both functions using your tips.

One more question. How can I determine whether player's character is sitting or not?

Roman.
Hook the "sit" key and every combat event that makes your character stand up? :/ Not really a wonderful idea... Maybe checking what actions are available when sitting and comparing to actions available only when standing could work... I'm not really sure how IsUsableAction handles this.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » IsPlayerMoving, IsPlayerTyping implementation

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