Graal Forums

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

coreys 05-16-2010 11:20 PM

Utility Collection
 
2 Attachment(s)
These are a few classes I've been using that I never really got around to making a proper release for (most of them don't warrant their own individual release). Some of them are likely to be added onto and changed later.

Most of them are fairly straightforward to understand, or they have documentation in the scripts.

util_common
Just a couple of simple functions I've needed. The first is a distance function that uses a heuristic. The second is a capitalization function.

util_dict
A simple associative array class. It doesn't use any fancy hash table lookups or anything, so it's probably not particularly efficient, but it gets the job done.

util_indent
A function to check the indentation of a line. Useful for parsing files where this may be necessary (I used it for parsing my behavior tree files).

util_path
The most useful (and lengthy) script in this collection. It's a wrapper around the built in findPathInArray() function. Since that function uses an awkward map array format and doesn't make particularly pretty paths (no diagonals) my function post-processes the generated path to make it better (though not much better, yet).

It's fairly well documented in the script, but just know that it also accounts for an NPC's size and where it should be blocked.

It also contains a function for traversing through the path, to make it simpler for you.

util_requesthttp2
To be honest, this isn't tested very well, but seeing as it's largely Inverness' util_sql but rewritten for requestHttp(), I don't see there being any issues with it, but please let me know if there are.

util_sleep2
An attempt to get around the issues with using sleep() inside of a timeout loop. Though it will still cause problems if used before setTimer() is called, if done afterwards it works fine.

DrakilorP2P 05-17-2010 05:42 PM

Quote:

Originally Posted by coreys (Post 1576713)
distance function that uses a heuristic..

Why?

Quote:

Originally Posted by coreys (Post 1576713)
util_dict
A simple associative array class. It doesn't use any fancy hash table lookups or anything, so it's probably not particularly efficient, but it gets the job done.

Should have used dynamic variable names. :)

coreys 05-17-2010 07:31 PM

Quote:

Originally Posted by DrakilorP2P (Post 1576880)
Why?

Because it's faster (square root is slow) and was more appropriate for some of the things I was using it for. For example, it helped speed up our hit detection on Rebirth quite a bit.

Quote:

Originally Posted by DrakilorP2P (Post 1576880)
Should have used dynamic variable names. :)

I didn't want the possibility of interfering with built in variables or the function objects (especially that last one).


All times are GMT +2. The time now is 11:05 AM.

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