Thread: onKeyPressed()
View Single Post
  #9  
Old 08-21-2009, 09:39 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Gambet View Post
That's a bit vague for someone that might not be familiar with loops since they wouldn't realize that they would benefit from using one in this case:

PHP Code:
function onKeyPressed() {
  for (
temp.key 0temp.key 4temp.key++) {
    if (
keydown(key)) {
      
player.chat "directional key pressed";
    }
  }


Stuff like this has been posted before, possibly in multiple threads, people should really use the search function, they would get answers to their questions much faster.


EDIT: It's probably better to say 'directional key pressed' instead of 'arrow key pressed' since that would imply that the script would only trigger when you press an arrow key, when in fact it would trigger whenever you pressed any of the directional keys that you have set in your F3 options.
Eh, I was more providing the values he could use(0-3) rather than implying he should loop... which he should.

As for arrows vs directional... probably, but it should always be applied to the customization of the player. If the player chooses to use WASD as their directional keys, this should also apply to whatever GUI's the player is using, so really directional translates into arrow as the player customizes them to basically be such(even if they're regular keys instead of the arrow keys). Developers need to keep that in mind.
Reply With Quote