![]() |
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). |
You can make a weapon invisible in your classic inventory (if you don't want to change it) by putting a - before its name, like:
-Playerstuffs Do I recall correctly ? Been ages I didn't use this duh |
That's right Soala, and a * as a prefix will make it show up, but you won't be able to delete in.
|
Quote:
|
+Rep
|
Quote:
- : hides the inventory * : can't be deleted by player category/itemname : Organizes the weapons in category names. However, these aren't exactly script functions, so much as client features :) |
Quote:
|
Quote:
|
Dynamic function calling.
I.e: PHP Code:
|
Another handy thing is assigning WNPCs to vars. Let's say you got the following in -System/Inventory:
PHP Code:
PHP Code:
|
It was playersprite, not player.sprite :0
|
Quote:
|
Quote:
I see uses. |
bump for requesting stickythready.
|
Quote:
|
All times are GMT +2. The time now is 08:53 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.