PDA

View Full Version : grab


theHAWKER
08-27-2007, 06:59 AM
Whats the function for grabbing the npc?

ive tryed making my own but its in-acurate x.x

DustyPorViva
08-27-2007, 07:03 AM
Umm, when the NPC is grabbed?
I don't think there is one.

theHAWKER
08-27-2007, 07:29 AM
Umm, when the NPC is grabbed?
I don't think there is one.

i could have swarn...

then how might u go about doing that?

DustyPorViva
08-27-2007, 07:33 AM
There is onActionpushed/pulled, but no grabbed.
You do so by simply performing a triggeraction on keydown(6).
function onKeypressed() {
if (keydown(6)) triggeraction(player.x+1.5+vecx(player.dir)*2,play er.y+2.5+vecy(player.dir)*2,"grabbed",parameters...);
}

Then, in the NPC, you do something like:
function onActiongrabbed() {
this.chat="Oh no, some pervert is grabbing me!";
}

theHAWKER
08-27-2007, 07:40 AM
There is onActionpushed/pulled, but no grabbed.
You do so by simply performing a triggeraction on keydown(6).
function onKeypressed() {
if (keydown(6)) triggeraction(player.x+1.5+vecx(player.dir)*2,play er.y+2.5+vecy(player.dir)*2,"grabbed",parameters...);
}

Then, in the NPC, you do something like:
function onActiongrabbed() {
this.chat="Oh no, some pervert is grabbing me!";
}

:O thank you :DD

ToNy_W
08-27-2007, 06:35 PM
If you keep your finger on the key for a second it'll start spamming the action though o.O
I've always wondered how bad it can be to spam triggeraction like that, i know it can be done on some servers since they use the onKeyPressed event, but wouldn't it eventualy start lagging if 5 players decided to grab a wall at the same time for a couple minutes?

Chompy
08-27-2007, 07:28 PM
If you keep your finger on the key for a second it'll start spamming the action though o.O
I've always wondered how bad it can be to spam triggeraction like that, i know it can be done on some servers since they use the onKeyPressed event, but wouldn't it eventualy start lagging if 5 players decided to grab a wall at the same time for a couple minutes?

Depends..

If the 5 players grabbed some fancy objects that did all crap like loading files, requestiing urls and **** it could lag if there was enough players..

But there is always lag, you just don't notice it :p

DustyPorViva
08-27-2007, 09:26 PM
Well that's easy to stop:
function onKeypressed() {
if (keydown(6)) {
if (temp.keydown==false) {
triggeraction(player.x+1.5+vecx(player.dir)*2,play er.y+2.5+vecy(player.dir)*2,"grabbed",parameters...);
temp.keydown=true;
}
} else temp.keydown=false;
}

Chompy
08-27-2007, 09:49 PM
Well that's easy to stop:
function onKeypressed() {
if (keydown(6)) {
if (temp.keydown==false) {
triggeraction(player.x+1.5+vecx(player.dir)*2,play er.y+2.5+vecy(player.dir)*2,"grabbed",parameters...);
temp.keydown=true;
}
} else temp.keydown=false;
}

That wouldn't be needed, since that event woulød only be triggered when the player presses a key :p
(PS: this. instead of temp.)

DustyPorViva
08-27-2007, 10:11 PM
Well, the problem is onKeypressed will repeat while the button is held down(much like holding a key down like thissssssssss), so it won't only be called once. That script makes it so it will only work when the key is first pressed, and won't work until it's released.

Chompy
08-27-2007, 10:25 PM
Well, the problem is onKeypressed will repeat while the button is held down(much like holding a key down like thissssssssss), so it won't only be called once. That script makes it so it will only work when the key is first pressed, and won't work until it's released.

hmm, I see what you mean, but now I see that they should be this.
as if when you hold down the key, it will trigger the event on new, and on new etc.. all the time, thus in clearing the temp. variables

DustyPorViva
08-27-2007, 10:29 PM
Ya, that'll need to be changed to this. instead of temp.

ToNy_W
08-28-2007, 12:22 AM
the easiest solution is still to add the grab detection inside your custom movement system's timeout >=o!
I never liked working with the onKeypressed event for graal... Doesn't really make sense to me that the event is triggered over and over again as long as the key is held down x-x

DustyPorViva
08-28-2007, 12:26 AM
Well first, that requires them to have a custom movement, this assumes they don't.
Second, Graal has no control over the repeated sending of onKeypressed. This is something with keyboards, as long as the key is held down, it'll repeatedly send the key bring pressed. Graal simply grabs that information, it can't stop it from repeating the key.

zokemon
08-28-2007, 10:57 AM
Well first, that requires them to have a custom movement, this assumes they don't.
Second, Graal has no control over the repeated sending of onKeypressed. This is something with keyboards, as long as the key is held down, it'll repeatedly send the key bring pressed. Graal simply grabs that information, it can't stop it from repeating the key.

It can detect this through when the key is held and when not held though. But this was made like so such that it worked like a word processing program (hold a letter down). It certainly has many uses and I'm glad it's there.