Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   keyDown check? (https://forums.graalonline.com/forums/showthread.php?t=68762)

projectigi 09-16-2006 03:01 PM

keyDown check?
 
Hi,

i made a TDrawingPanel(in the TDrawingPanel there a GUIWindowCtrl that goes all over the screen and is on the top,
for some reason the keydown check ( onKeyPressed, keyDown2 ) doesnt work anymore now XD
how do i make em working again?

Skyld 09-16-2006 04:00 PM

PHP Code:

GraalControl.makeFirstResponder(); 

I think.

projectigi 09-16-2006 05:11 PM

doesnt work =/
when i make ()
it says
Quote:

GraalScript: Not enough parameters for makefirstresponder (1 needed, 0 given) in script of Weapon projectigi/mapeditor
and when i give a bool(be it true or false) it doesnt work too ~.~

KuJi 09-16-2006 06:45 PM

Should be:

PHP Code:

GraalControl.makefirstresponder(true); 


xXziroXx 09-16-2006 08:58 PM

Quote:

Originally Posted by projectigi
Hi,

i made a TDrawingPanel(in the TDrawingPanel there a GUIWindowCtrl that goes all over the screen and is on the top,
for some reason the keydown check ( onKeyPressed, keyDown2 ) doesnt work anymore now XD
how do i make em working again?

Example:

PHP Code:

function onCreated()
{
  new 
GuiWindowCtrl("MainWindow") {
     
// stuff
  
}
  
MainWindow.makeFirstResponder("false");



projectigi 09-16-2006 09:40 PM

doesnt work :<

xXziroXx 09-16-2006 10:04 PM

Works for me..

projectigi 09-16-2006 10:13 PM

and doesnt for me <.<

xXziroXx 09-16-2006 10:26 PM

Maybe if you posted parts of the script so that we could try and see whats wrong?

projectigi 09-16-2006 10:50 PM

nvm, does work now :P

projectigi 09-16-2006 11:07 PM

is there a workaround for loop limit exceeded?

Skyld 09-16-2006 11:17 PM

Quote:

Originally Posted by projectigi
is there a workaround for loop limit exceeded?

Make your loop smaller. :)

projectigi 09-16-2006 11:28 PM

how would i fill a [255][255] array then

contiga 09-18-2006 03:01 PM

Post your current loop that gets exceeded.. I'll see wut I can do.

projectigi 09-18-2006 04:13 PM

NPC Code:

for( this.dy = 0; this.dy < 128; this.i1++ )
{
for( this.dx = 0; this.dx < 128; this.dx++ )
{
this.map[ this.dx ][ this.dy ] = int( random( 1, 3.99 ));
}
}


thats my loop :P

contiga 09-18-2006 04:17 PM

Quote:

Originally Posted by projectigi
PHP Code:

// I am bad, I use code tags.
for( this.dy 0this.dy 128this.i1++ ) // this.i1++? this.dy ++ you mean
  
{
  for( 
this.dx 0this.dx 128this.dx++ )
    {
    
this.mapthis.dx ][ this.dy ] = intrandom13.99 ));
    }
  } 

thats my loop :P

Try this tho, I more like it that way;
PHP Code:

for ( 0128 2++) {
  
this.dx 128;
  
this.dy int128);
  
this.mapthis.dx][ this.dy] = intrandom13.99));


Tho it won't work, since 128 ^ 2 > 10.000, and will exceed the loop limit :whatever:

And make sure this.map is created already as an array.

projectigi 09-18-2006 04:59 PM

is there a fps counter in graal?

contiga 09-18-2006 05:17 PM

Frames Per Second? Not that I know off.

Tolnaftate2004 09-18-2006 07:07 PM

One could do:
PHP Code:

temp.keys "";
 for (
temp.i=0;temp.i<128;temp.i++) temp.keys.add(temp.i);

 for (
temp.i=0;temp.i<128;temp.i++) {
   
temp.key int(random(0,128-.001));
   
this.map[temp.i][temp.key] = int(random(0,3.99));
   
temp.keys.delete(temp.key);
 } 


contiga 09-18-2006 07:45 PM

Quote:

Originally Posted by Tolnaftate2004
One could do:
PHP Code:

temp.keys "";
 for (
temp.i=0;temp.i<128;temp.i++) temp.keys.add(temp.i);

 for (
temp.i=0;temp.i<128;temp.i++) {
   
temp.key int(random(0,128-.001));
   
this.map[temp.i][temp.key] = int(random(0,3.99));
   
temp.keys.delete(temp.key);
 } 


Uhh.. that's not gonna work I think :p (For what he wants it to do).

Tolnaftate2004 09-18-2006 08:00 PM

Quote:

Originally Posted by contiga
Uhh.. that's not gonna work I think :p (For what he wants it to do).

Just realized, you are right, my mistake.

CheeToS2 09-18-2006 08:52 PM

Quote:

Originally Posted by projectigi
NPC Code:

for( this.dy = 0; this.dy < 128; this.i1++ )
{
for( this.dx = 0; this.dx < 128; this.dx++ )
{
this.map[ this.dx ][ this.dy ] = int( random( 1, 3.99 ));
}
}


thats my loop :P

NPC Code:
for( this.dy = 0; this.dy < 128; this.i1++ )



You are adding this.i1 instead of this.dy, which I assume you meant to do. That is going to cause an infinite loop.

projectigi 09-18-2006 10:27 PM

yeah forgot to change this :P
still the loop won't work for 500x500 map arrays
how is the loop limit calculated? is it just like at the end of every loop you do this.foobar++; and when this.foobar>=10000 echo("blub... limit exceeded..."); break;
or something like this?

Tyrial 09-18-2006 11:44 PM

Is there no builtin command that values the length of a <something>?

Like in Java, you can use Integer.MAX_VALUE or such.. Perhaps this.MAX_VALUE? Don't know.. try.

projectigi 09-19-2006 10:45 PM

huh?
contiga: what code tags?

KuJi 09-20-2006 12:21 AM

Quote:

Originally Posted by Tyrial (Post 1219443)
Is there no builtin command that values the length of a <something>?

Like in Java, you can use Integer.MAX_VALUE or such.. Perhaps this.MAX_VALUE? Don't know.. try.

like this.blah.length();?

Skyld 09-20-2006 09:03 AM

Quote:

Originally Posted by Tyrial (Post 1219443)
Is there no builtin command that values the length of a <something>?

Like in Java, you can use Integer.MAX_VALUE or such.. Perhaps this.MAX_VALUE? Don't know.. try.

If you mean is there a way to find out the maximum value of a specific type of data (like you might do sizeof(int) in C), then no, there isn't such a thing in GScript.

If you are just looking for the length of the current data, then yes, obj.length() is correct.

contiga 09-20-2006 02:43 PM

Quote:

Originally Posted by projectigi (Post 1219592)
huh?
contiga: what code tags?

NPC Code:
function blabla()
// foo



PHP Code:

function blabla()
  
// foo 

I more like the PHP tags instead of the CODE tags, it's easier to read scripts with the hightlighting.. Btw, my highlighting in RC doesn't work no more! (As I posted in bug thread or so), someone knows why?


All times are GMT +2. The time now is 02:53 AM.

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