Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Gralats (https://forums.graalonline.com/forums/showthread.php?t=73835)

Chandler 05-05-2007 07:12 PM

Gralats
 
HTML Code:

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 07:15 PM

I never understood how Gani params work and still don't, explain.

Chandler 05-05-2007 07:19 PM

Quote:

Originally Posted by Rapidwolve (Post 1305694)
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 07:24 PM

...What?

Chandler 05-05-2007 07:25 PM

ganiName[1] = frame 1 of the ganiName gani
walk[0] = frame 0 of the walk gani.

Easier? :p

Rapidwolve 05-05-2007 08: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 09: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 09: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:

PHP Code:

function onKeyPressedkeynrkeyname )
{
  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 09:09 PM

Quote:

Originally Posted by killerogue (Post 1305722)
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 09: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 09: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 10: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 03:19 AM

Yeah I get it now.

theHAWKER 05-06-2007 08:05 PM

whats this do?
and whats it for?

Chandler 05-06-2007 08:07 PM

The gralat class re-scripted.

Twinny 05-06-2007 08:13 PM

Quote:

Originally Posted by theHAWKER (Post 1305922)
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
PHP Code:

if (updategani)
{
  
this.updategani();


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

Chandler 05-06-2007 08:23 PM

I don't really know much about the class. I just re-scripted it.

Riot 05-06-2007 10:02 PM

Quote:

Originally Posted by Twinny (Post 1305927)
He's rewritten the default graalats class into GS2 and added a for loop for some strange reason x_x.

Also, for
PHP Code:

if (updategani)
{
  
this.updategani();


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

HTML Code:

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

I use it in the Gralats class I rescripted awhile ago

Sum41Freeeeek 05-07-2007 12:59 AM

PHP Code:

if (updategani)

function 
updategani() 

isn't that the same thing?

why would you do

PHP Code:

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

if (
updategani)
{
  
this.updategani();


aren't you doing the same thing twice?

Rapidwolve 05-07-2007 01:02 AM

Quote:

Originally Posted by Sum41Freeeeek (Post 1305972)
PHP Code:

if (updategani)

function 
updategani() 

isn't that the same thing?

why would you do

PHP Code:

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 01:52 AM

Quote:

Originally Posted by Rapidwolve (Post 1305973)
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!


All times are GMT +2. The time now is 01:49 AM.

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