Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Needs help with keydown (https://forums.graalonline.com/forums/showthread.php?t=7784)

Jerom 07-21-2001 05:32 PM

Needs help with keydown
 
To start out this post...I suck at scripting!!!
I was making the starting movement for a race and I couldn't make it so that the player stops using walk.gani and uses idle.gani when the player isn't moving. Right now the player just moves all the time.
Here's the script, could you help me out(i added the onwall incase that may be of any good use)?:
if (playertouchsme) {
toweapons System;
disabledefmovement;
timeout=0.05;}
if (timeout) {
if (keydown(0)){
playerdir = 0;
playery-=0.5;
setani walkslow,;
}
if (keydown(1)){
playerdir = 1;
playerx-=0.5;
setani walkslow,;
}
if (keydown(2)){
playerdir = 2;
playery+=0.5;
setani walkslow,;
timeout=0.05;
}
if (keydown(3)){
playerdir = 3;
playerx+=0.5;
setani walkslow,;
}
timeout=0.05;
//left detection
if (onwall(playerx+0.5,playery+1.5)) {playerx+=0.5}
if (onwall(playerx+0.5,playery+2)){playerx+=0.5}

//right detection
if (onwall(playerx+2,playery+1.5)) {playerx-=0.5}
if (onwall(playerx+2,playery+2)) {playerx-=0.5}

//down detection
if (onwall(playerx+0.5,playery+2.5)) {playery-=0.5}
if (onwall(playerx+1,playery+2.5)) {playery-=0.5}
if (onwall(playerx+1.5,playery+2.5)) {playery-=0.5}

//up detection
if (onwall(playerx+0.5,playery+1)) {playery+=0.5}
if (onwall(playerx+1,playery+1)) {playery+=0.5}
if (onwall(playerx+1.5,playery+1)) {playery+=0.5}

NeoNPL 07-21-2001 05:35 PM

Ok whats it supposed to do if u post the ganis ill look at it offline and see the problem

Loriel 07-21-2001 05:50 PM

for (i=0; i<4; i++) {
if (keydown(i) {
setani walkslow,;
break;
} else
setani idle,;
}
I dunno if that would work, but it should.
*is pretty sure there is a very obvious mistake in there*

Jerom 07-21-2001 06:02 PM

It's not working =(
I checked it in the editor and it says for the part,
----
for (i=0; i<4; i++) {
if (keydown(i) {
setani walkslow,;
break;
} else
setani idle,;
}
----
"Error: Expected format: if (flag) command;"
<edited>
for (i=0; i<4; i++)) {
if (keydown(i) {
setani walkslow,;
break;
} else
setani idle,;
}
//he forgot the extra ) after the for part

Merlin2 07-21-2001 07:48 PM

Quote:

Originally posted by Jerom
It's not working =(
I checked it in the editor and it says for the part,
----
for (i=0; i<4; i++) {
if (keydown(i) {
setani walkslow,;
break;
} else
setani idle,;
}
----
"Error: Expected format: if (flag) command;"
<edited>
for (i=0; i<4; i++)) {
if (keydown(i) {
setani walkslow,;
break;
} else
setani idle,;
}
//he forgot the extra ) after the for part


I'll help, but I want off ignore ;)
timeout=.50;
if (playertouchsme) {
toweapons System;
disabledefmovement;
timeout=0.05;}
if (timeout) {
if (keydown(0)){
playerdir = 0;
playery-=0.5;
setani walkslow,;
}
if (keydown(1)){
playerdir = 1;
playerx-=0.5;
setani walkslow,;
}
if (keydown(2)){
playerdir = 2;
playery+=0.5;
setani walkslow,;
timeout=0.05;
}
if (keydown(3)){
playerdir = 3;
playerx+=0.5;
setani walkslow,;
}
timeout=0.05;
//left detection
if (onwall(playerx+0.5,playery+1.5)) {playerx+=0.5}
if (onwall(playerx+0.5,playery+2)){playerx+=0.5}

//right detection
if (onwall(playerx+2,playery+1.5)) {playerx-=0.5}
if (onwall(playerx+2,playery+2)) {playerx-=0.5}

//down detection
if (onwall(playerx+0.5,playery+2.5)) {playery-=0.5}
if (onwall(playerx+1,playery+2.5)) {playery-=0.5}
if (onwall(playerx+1.5,playery+2.5)) {playery-=0.5}

//up detection
if (onwall(playerx+0.5,playery+1)) {playery+=0.5}
if (onwall(playerx+1,playery+1)) {playery+=0.5}
if (onwall(playerx+1.5,playery+1)) {playery+=0.5}


You've been cursed with darklink wub.

What I done was added "timeout=.50" at top, hehehehe. It should work >.<

Jerom 07-21-2001 08:23 PM

I already had a timeout set:timeout = 0.05
I've used some stuff Loriel's given me. I just need to find out where to use it and what else to add.

Merlin 07-22-2001 12:19 AM

the problem with loriel's is after the if (keydown(0)
theres only one ")" and there needs to be 2
if (keydown(0)) i think

Jerom 07-22-2001 02:19 AM

Quote:

Originally posted by Jerom
It's not working =(
I checked it in the editor and it says for the part,
----
for (i=0; i<4; i++) {
if (keydown(i) {
setani walkslow,;
break;
} else
setani idle,;
}
----
"Error: Expected format: if (flag) command;"
<edited>
for (i=0; i<4; i++)) {
if (keydown(i) {
setani walkslow,;
break;
} else
setani idle,;
}
//he forgot the extra ) after the for part

I already pointed that out in the post above. Loriel even told me in a PM he forgot that when i told him it didn't work.

Solareon 07-22-2001 04:11 AM

hummmm
 
if you intend to have your player world non p2p you can't have different races, you could try using replaceani and screw keydown and all that, replaceani needs a p2p server though

07-22-2001 02:13 PM

use while true...

grim_squeaker_x 07-22-2001 05:53 PM

Quote:

Originally posted by IcePick_2001
use while true...
Hi, using while (true) would mean that you can't use that system NPC in combination with triggeraction anymore, bye.


All times are GMT +2. The time now is 10:03 AM.

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