Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-21-2002, 12:58 PM
Zigidias Zigidias is offline
Registered User
Join Date: Nov 2002
Location: USA
Posts: 73
Zigidias is on a distinguished road
Send a message via AIM to Zigidias
keydown()

Is it jsut me or does keydown(#) finction not work very well?, it doesnt seem very reliable. Is there a better way?
__________________
Reply With Quote
  #2  
Old 11-21-2002, 08:26 PM
Zigidias Zigidias is offline
Registered User
Join Date: Nov 2002
Location: USA
Posts: 73
Zigidias is on a distinguished road
Send a message via AIM to Zigidias
so...

NPC Code:

if (keydown(9))
{
// commands
}



wont execute?
then how do i see if a button is pressed?
__________________
Reply With Quote
  #3  
Old 11-21-2002, 11:04 PM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
You're assuming it as an action. Unlike keypressed, where it calls the action, keydown and keydown2 are best used in a timeout. Generally I do a clientside timeout of .05 and then do it. so:
NPC Code:

if (timeout)
{ if (keydown(0))
{ playery = playery-.1;}
timeout=0.05;
}


I can guarantee you that will work Also, if you're using keydown2 it requires(key,true/false) I believe. So if keydown2(8,true) then it will perform the function. It AGAIN is NOT an action but a function as Kai calls them. To me, everything in an if statement is an action or a non-action. If you can use it like if (playerchats) || if (playertouchsme) kind of stuff, then it's an action. if (strequals(#a,Projectshifter)) however is not. That does not run by itself. hope it helps, enjoy.
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #4  
Old 11-22-2002, 02:30 AM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
Personally, I would use a timeout of .1 when using keydowns because .05 is too sensitive.

-Ningnong
Reply With Quote
  #5  
Old 11-22-2002, 02:43 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally posted by Ningnong
Personally, I would use a timeout of .1 when using keydowns because .05 is too sensitive.

-Ningnong
Personally, I would use a timeout of 0.05 when using keydowns because 0.1 is too slow

No reason to use 0.1 clientside.
Reply With Quote
  #6  
Old 11-22-2002, 03:01 AM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
I hate .05's because you have to just "touch" the key, and you find your self getting your tap right before it works (like its on and of with one normal press)..
Reply With Quote
  #7  
Old 11-22-2002, 03:17 AM
Com013 Com013 is offline
Registered User
Join Date: Aug 2002
Location: GMT+1
Posts: 381
Com013 is on a distinguished road
Clientside I am most times using timeouts of 0.05 seconds.

The script should react immediatly and not lag behind a bit.
If you don't want the action to be repeated too often there are two ways.
The first way is to make sure that the key has been released before it has been repressed.
The second way is to count the time that has passed since the last action was triggered by the key.
__________________
Com013
Former Admin of the LAT on Graal The Adventure

e-mail: [email protected]
Reply With Quote
  #8  
Old 11-22-2002, 03:23 AM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
I dont use keydown so much...
keydown2 is better.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #9  
Old 11-22-2002, 03:43 AM
Com013 Com013 is offline
Registered User
Join Date: Aug 2002
Location: GMT+1
Posts: 381
Com013 is on a distinguished road
Quote:
Originally posted by osrs
I dont use keydown so much...
keydown2 is better.
Not when you want to access the default keys. The user might change them and then you are checking for the wrong keys when using keydown2.
__________________
Com013
Former Admin of the LAT on Graal The Adventure

e-mail: [email protected]
Reply With Quote
  #10  
Old 11-22-2002, 06:12 AM
Zigidias Zigidias is offline
Registered User
Join Date: Nov 2002
Location: USA
Posts: 73
Zigidias is on a distinguished road
Send a message via AIM to Zigidias
thanx to all of you, you helped out alot
__________________
Reply With Quote
  #11  
Old 11-22-2002, 06:18 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
.05 may have it repeat at times, but then again when you do a GUI or something, .1 may be not sensitive enough, people often just tap and release. I'd say set a variable.
NPC Code:

if (created)
{ this.tap=0; timeout=.05;}
if (timeout)
{ if (keydown(0) && this.tap==0)
{ action(); this.tap=1;}
if (!keydown(0) && this.tap==1)
{ this.tap=0;}
timeout=.05;
}


That may be the best way.
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #12  
Old 11-22-2002, 07:09 AM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Quote:
Originally posted by Ningnong
I hate .05's because you have to just "touch" the key, and you find your self getting your tap right before it works (like its on and of with one normal press)..
make an array that checks if it was false first before performing the action (.05 seconds ago), then you won't have to worry about holding it down with the .1 stuff, and you won't have to worry about tapping with the plain .05 stuff
__________________

Reply With Quote
  #13  
Old 11-22-2002, 10:40 PM
Com013 Com013 is offline
Registered User
Join Date: Aug 2002
Location: GMT+1
Posts: 381
Com013 is on a distinguished road
Ok, now the same thing has been said by me, Shifter and CheeToS2. Is there anybody else who wants to repeat it?
__________________
Com013
Former Admin of the LAT on Graal The Adventure

e-mail: [email protected]
Reply With Quote
  #14  
Old 11-23-2002, 01:19 AM
Delteria_Free18 Delteria_Free18 is offline
Registered User
Join Date: Oct 2002
Location: Phoenix, Arizona
Posts: 130
Delteria_Free18 is on a distinguished road
Send a message via ICQ to Delteria_Free18 Send a message via AIM to Delteria_Free18
nah, I'd say 3 times is a charm....
__________________
Before you make fun of someone, walk a mile in their shoes. Then, when you make fun of them, you'll be a mile away, and have their shoes.

........//////
.......( )
.-oo0-(_)-0oo-

Go To: Delteria.net :: Forums.Delteria.net ::
Reply With Quote
  #15  
Old 11-24-2002, 01:05 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
meh, I'd rather do

NPC Code:

if (keypressed && keydown(blah)) {
action;
}



but if it needs to be in a timeout, then do what has been said three or four times now...
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.