• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

BlzTriggerRegisterPlayerKeyEvent and TriggerRegisterPlayerMouseEventBJ

Status
Not open for further replies.

Deleted member 264867

D

Deleted member 264867

Hi, I've a problem that I can't really address while testing the 1.31 on Warcraft 3 PTR . Basically this code:

Code:
function test1() 
   clicktrig = CreateTrigger()
   keytrig = CreateTrigger()
   function click()
      print("click")
   end
   function key()
      print("key")
   end 
   BlzTriggerRegisterPlayerKeyEvent(keytrig,Player(0),OSKEY_W,0,true)
   BlzTriggerRegisterPlayerMouseEventBJ(clicktrig,Player(0),bj_MOUSEEVENTTYPE_DOWN)
   TriggerAddAction(keytrig,key)
   TriggerAddAction(clicktrig,click)

end

As well as this (which are pratically the same, but just to check every possibility):
Code:
function test2()
   trig= CreateTrigger()
   function action()
      if BlzGetTriggerPlayerKey()== OSKEY_W then
         print("key")
      end
      if BlzGetTriggerPlayerMouseButton()==MOUSE_BUTTON_TYPE_LEFT then
         print("click")
      end
   end
BlzTriggerRegisterPlayerKeyEvent(trig,Player(0),OSKEY_W,0,true)
TriggerRegisterPlayerMouseEventBJ(trig,Player(0),bj_MOUSEEVENTTYPE_DOWN)
TriggerAddAction(trig,action)
      
end

(I call the function inside a GUI trigger at Map initialization one per map run)
Work fine unless I press W and click the left mouse at roughly the same time, (enough to be noticabile) in which case it ignores the BlzzTriggerRegisterPlayerKeyEvent and only outputs "click" in both codes. I don't know if it supposed to be like that becouse of the difference in input lag between mouse and keyboard or what. Even if that was the case, wouldn't that mean only that ''w'' wuold be displayed slighlty after ''click''?
So my question is: is there a workaround for that? Is that a bug that could be fixed or will be 100% like this even in live 1.31?
I didn't try using JASS instead of Lua becouse I don't see of that could be of any help.
What I have tried is this code
Code:
function test3()
   trig= CreateTrigger()

   function test()
      if BlzGetTriggerPlayerKey()== OSKEY_W then
         print("W")
      end
      if BlzGetTriggerPlayerKey()== OSKEY_A then
         print("A")
      end
   end
BlzTriggerRegisterPlayerKeyEvent(trig,Player(0),OSKEY_W,0,true)
BlzTriggerRegisterPlayerKeyEvent(trig,Player(0),OSKEY_A,0,true)
TriggerAddAction(trig,test)
TriggerAddAction(clicktrig,click)
end

And it works perfectly fine.
Any thoughts?
Thanks for your time.
 
Last edited by a moderator:
Status
Not open for further replies.
Top