changeset 35:83cfab9dcb63 v1.0beta6

Weapon is not stealthed while moving and talking / Use a constant for short delay (0.5s) / the long delay is now 2.5s to avoid clipping with emotes
author contrebasse
date Sat, 08 Jan 2011 17:00:00 +0100
parents 6f99c7f30f15
children f5fa2c836a4f
files Degaine.lua
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Degaine.lua	Sat Jan 08 16:09:53 2011 +0100
+++ b/Degaine.lua	Sat Jan 08 17:00:00 2011 +0100
@@ -25,6 +25,7 @@
 -- Lua functions
 local pairs = pairs;
 local type = type;
+local select = select
 
 -- Wow functions
 local GetTime = GetTime
@@ -34,7 +35,7 @@
 local IsMounted = IsMounted
 local GetNumCompanions, GetCompanionInfo = GetNumCompanions, GetCompanionInfo
 local UnitCastingInfo = UnitCastingInfo
-local select = select
+local GetUnitSpeed = GetUnitSpeed
 
 
 ---------------------------------------------------------------
@@ -43,7 +44,8 @@
 -- const
 local DegaineFrame = CreateFrame("Frame")
 local playername = UnitName("player")
-local delay = 2 -- seconds
+local delay = 2.5 -- seconds
+local delay_short = 0.5 -- seconds
 
 -- vars
 local t_left = -1
@@ -165,10 +167,13 @@
 	-- Archaeology ?
 }
 
+local function playerIsNotMoving()
+	return GetUnitSpeed("player") == 0
+end
 local events2playername = { -- the 2nd arg is playername
-	CHAT_MSG_SAY = true,
-	CHAT_MSG_YELL = true,
-	CHAT_MSG_TEXT_EMOTE = true,
+	CHAT_MSG_SAY = playerIsNotMoving,
+	CHAT_MSG_YELL = playerIsNotMoving,
+	CHAT_MSG_TEXT_EMOTE = true, -- the emote is not shown, but the weapon is stealthed
 }
 
 
@@ -190,7 +195,7 @@
 			wasMounted = true
 		else
 			if wasMounted then
-				start(0.5) -- no animation for unmounting
+				start(delay_short) -- no animation for unmounting
 				wasMounted = false
 			end
 		end
@@ -288,11 +293,11 @@
 			--elseif arg5 and not SpellBlackList[arg5] then -- arg5 is SpellID
 			elseif (arg5 and SpellWhiteList[arg5]) or isTradeSkill then -- arg5 is SpellID
 				isTradeSkill = false -- for next time
-				start(0.5)
+				start(delay_short)
 			end
 		end
 	elseif events2playername[event] then
-		if arg2==playername then
+		if arg2==playername and (type(events2playername[event])~="function" or events2playername[event]()) then
 			start()
 		end
 	elseif event == "GOSSIP_CLOSED" then