PDA

View Full Version : keyDown check?


projectigi
09-16-2006, 03:01 PM
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
GraalControl.makeFirstResponder();
I think.

projectigi
09-16-2006, 05:11 PM
doesnt work =/
when i make ()
it says

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:

GraalControl.makefirstresponder(true);

xXziroXx
09-16-2006, 08:58 PM
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:


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
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
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
// I am bad, I use code tags.
for( this.dy = 0; this.dy < 128; this.i1++ ) // this.i1++? this.dy ++ you mean
{
for( this.dx = 0; this.dx < 128; this.dx++ )
{
this.map[ this.dx ][ this.dy ] = int( random( 1, 3.99 ));
}
}

thats my loop :P

Try this tho, I more like it that way;

for ( i = 0; i < 128 ^ 2; i ++) {
this.dx = i % 128;
this.dy = int( i / 128);
this.map[ this.dx][ this.dy] = int( random( 1, 3.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:
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
One could do:
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
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
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

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
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
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
huh?
contiga: what code tags?

function blabla()
// foo

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?