PDA

View Full Version : Gralats


Chandler
05-05-2007, 08:12 PM
function onCreated()
{
this.showcharacter();
this.updategani();
}

if (updategani)
{
this.updategani();
}

function updategani()
{
temp.gType = 1;
temp.rupeeAmounts = {{5, 2}, {30, 3}, {100, 4}};
for (temp.curAmount: temp.rupeeAmounts)
{
if (rupees >= temp.curAmount[0])
{
temp.gType = temp.curAmount[1];
}
}
this.setcharani("gralats", temp.gType);
}

function onPlayerTouchsMe()
{
player.rupees += rupees;
this.destroy();
}

//#CLIENTSIDE
function onCreated()
{
this.blockAgain();
}


Some fun

Rapidwolve
05-05-2007, 08:15 PM
I never understood how Gani params work and still don't, explain.

Chandler
05-05-2007, 08:19 PM
I never understood how Gani params work and still don't, explain.

Your best bet is to have fun with it.


Basically, treat the gani as an array. [Each param to that ''array'' is classed as the frame]

killerogue
05-05-2007, 08:24 PM
...What?

Chandler
05-05-2007, 08:25 PM
ganiName[1] = frame 1 of the ganiName gani
walk[0] = frame 0 of the walk gani.

Easier? :p

Rapidwolve
05-05-2007, 09:49 PM
Kind of, I've already tried to learn. I've noticed that with gani params on the sprites inside of the gani it has a (#). Is that needed?

No idea if I explained that correctly

cbk1994
05-05-2007, 10:01 PM
setAni( "GANINAME", PARAM1, PARAM2, PARAM3, [...] );

that explain?

In the gani script, use if (created) and then params[0], etc.
You have to use if (created) because onCreated as a function erases those params. To access the params in the gani, use PARAM1, PARAM2, PARAM3, PARAM4

for example, you could make a gani of a 32x32 image you want to drop for example, do this:
setCharAni( "dropitem", "block.png" );
than instead of in the gani putting an image when you add a sprite, put PARAM1.

killerogue
05-05-2007, 10:07 PM
Wait wait wait, What?

So basically I could use that for equipping things to my player like if I had custom bodies?

Like I could use that to set the images or something? Example:


function onKeyPressed( keynr, keyname )
{
if ( keyname == "s" )
{
setani( "od_custom_swing", clientr.equippedWep[3] );
}
}


So it would swing with the current image that is set to that index of the clientr array set to the player of their currently equipped weapon?

Rapidwolve
05-05-2007, 10:09 PM
So it would swing with the current image that is set to that index of the clientr array set to the player of their currently equipped weapon?

Yes, thats how most servers do it, they have one gani and fixed images rather then alot of gani's. I just don't know how to read the param in the actual gani o-o

killerogue
05-05-2007, 10:11 PM
Ho ho! I'm about to have a field day, I was planning on doing something similar to that but didn't know how! For loops will do just fine. =D

DustyPorViva
05-05-2007, 10:12 PM
You're passing parameters to the GANI. Inside the gani, either through graalshop or notepad, you can access those parameters.
Like in Chandler's script he is passing the numbers 0-4, for each type of gralat. In the gani, the sprite being displayed is the number of the parameter. So if it's a green gralat, the number 0 is being passed as the parameter, and sprite 0 is being displayed. It's best to look at the gani's as well, so you can understand what they're being used for.

cbk1994
05-05-2007, 11:24 PM
The sprite should be PARAM1.

then do
setAni( "ANINAME", "swordimage.png" );

then if all your swords use the same template, it's a hell of a lot less ganis.

killerogue
05-06-2007, 04:19 AM
Yeah I get it now.

theHAWKER
05-06-2007, 09:05 PM
whats this do?
and whats it for?

Chandler
05-06-2007, 09:07 PM
The gralat class re-scripted.

Twinny
05-06-2007, 09:13 PM
whats this do?
and whats it for?

He's rewritten the default graalats class into GS2 and added a for loop for some strange reason x_x.

Also, for

if (updategani)
{
this.updategani();
}


Is there any way to write that as an event rather than a condition? =x

Chandler
05-06-2007, 09:23 PM
I don't really know much about the class. I just re-scripted it.

Riot
05-06-2007, 11:02 PM
He's rewritten the default graalats class into GS2 and added a for loop for some strange reason x_x.

Also, for

if (updategani)
{
this.updategani();
}


Is there any way to write that as an event rather than a condition? =x

function onUpdateGani()
{
this.updategani();
}

I use it in the Gralats class I rescripted awhile ago

Sum41Freeeeek
05-07-2007, 01:59 AM
if (updategani)

function updategani()

isn't that the same thing?

why would you do

function onCreated()
{
this.updategani();
}

if (updategani)
{
this.updategani();
}

aren't you doing the same thing twice?

Rapidwolve
05-07-2007, 02:02 AM
if (updategani)

function updategani()

isn't that the same thing?

why would you do

function onCreated()
{
this.updategani();
}

if (updategani)
{
this.updategani();
}

aren't you doing the same thing twice?

That isnt what he is doing.
He is making the function loop itself

cbk1994
05-07-2007, 02:52 AM
That isnt what he is doing.
He is making the function loop itself

Wont that exceed the loop limit? I thought you had to use a timeout, or at least pause!