Author Topic: keypressed  (Read 1777 times)

0 Members and 1 Guest are viewing this topic.

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Minecraft
    • Steam
The isKeyPressed function seems to be disabled in lua.cpp, is there another way to get that data? I mean if a certain key is pressed ingame.
I tried looking in some of the example scripts but i've been out of luck so far.
el hombre vicio...

 

Offline Droid803

  • Trusted poster of legit stuff
  • 213
  • /人 ◕ ‿‿ ◕ 人\ Do you want to be a Magical Girl?
    • Skype
    • Steam
The Zoom script uses it IIRC.

EDIT: nope, it uses $On Key Pressed, never mind.
(´・ω・`)
=============================================================

 

Offline m!m

  • 211
You could still use $On Key Pressed and set a global variable to get your information.

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Minecraft
    • Steam
I tried copying the zoom script but I can't find the way to capture the key, I think I'm missing the way the $On Key Pressed works, should I declare a global variable and then what?

From what I can understand from reading the scripting entries on the wiki, that conditional hook will run every time ANY key is pressed... or am I mistaken and it actually checks which key was pressed?
el hombre vicio...

 

Offline m!m

  • 211
If you want to know the current key at any time you can save the pressed key from $On Key Pressed in a global variable and reset it in $On Key Released.

If you want to know whether a specific key is pressed just use
Code: [Select]
if hv.Key:lower() == "<key here>" then ... and set a global boolean if the pressed key matches your key.

Or you can use the $KeyPress condition and set your wanted key there.

From what I read I would suggest using the third approach as it's the easiest.

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Minecraft
    • Steam
Yeah I tried using your method with hv.Key:lower() , but I guess I used it in incorrectly.

Will try again later today, thanks!
el hombre vicio...