• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

BlzTriggerRegisterPlayerKeyEvent and TriggerRegisterPlayerMouseEventBJ

Status
Not open for further replies.
Level 3
Joined
Mar 3, 2018
Messages
15
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:
Status
Not open for further replies.
Top