Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-11-2010, 09:17 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Tips and tricks!

Post various things not exactly documented. I know there is a page on the wiki about it, but all it does is link to various forum threads.


Comparing arrays! You can easily compare two arrays without having to run a loop, provided the two arrays are exactly the same, in the same order. This is good... for example, comparing tiles. Props go to Skyld for teaching me this one, I believe.

if (@this.arrayOne == @this.arrayTwo) // YAY!
or
if (@this.arrayOne == @{0,0,1,1}) // YAY!


This works by converting the arrays into strings, in which Graal simply compares them, much like "foo" == "foo".


Another one that's been floating around is the ability to setAni to specific frames. This is useful sometimes when you need a specific frame of a gani(like a single sword frame), or perhaps scripting your own looping system where you can control the speed of a gani by script. You can use this to duplicate the old player.sprite system.

setAni("sword[3]",null); // MAKE SURE THE VALUE IS PART OF THE STRING!
setAni("walk[" @ foo @ "]",null);
setAni("def[" @ spritenum @ "]",null); // WILL MIMIC player.sprite FROM GS1



Forming dynamic variable names! Probably something anyone who's been scripting for a while knows how to do, but I think is useful for those who are newer to the GS2 scene. You can use variable values to create new variable names.

temp.foo = 1;
temp.var = 2;
client.("data_" @ foo) = "test";
("client.data_" @ var) = "hmm";


What makes this even more powerful is the ability to capture all variables that begin with a certain string:

temp.prefix = "client.data_";
for (temp.i : getstringkeys(prefix) {
..// WILL ECHO THE NAME OF THE VAR AND ITS VALUE
..echo((prefix @ i) @ " : " @ makevar(prefix @ i));
}


For more information on this, the original post may help: http://forums.graalonline.com/forums...70&postcount=6


You can also pass parameters along with attributes. The process is fairly easy:

player.attr[5] = "scriptgani.gani,foo";
player.attr[5] = "scriptgani.gani,foo,hmm";
player.attr[5] = "scriptgani.gani," @ temp.var;
player.attr[5] = "scriptgani.gani," @ temp.var @ "," @ temp.foo;


The original post from Stefan is here: http://forums.graalonline.com/forums...61&postcount=3
Be aware though, that parameters do not update until the attribute is cleared and then reset. This makes it somewhat useless for attributes that are constant(like an HP bar).


This is all I have for now, though it was never even intended to be this long. I'd love to see more posts written that share some more unknown information so we can get it organized and hopefully easy-to-read. Maybe eventually it can be converted into a wiki page in itself(I can't edit the wiki though).

Last edited by DustyPorViva; 02-11-2010 at 09:35 PM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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