![]() |
Shared functions pack
I'm happy to introduce the new clientside shared functions pack. It's a clientside script added to players when they log into Graal, providing new public functions that are available for all servers to use. These are general functions that you might just find handy to speed the scripting process up. It also enables us to provide some new functions quickly without client updates.
Currently the pack just provides a few odd functions, however more will become available in due course. If you have some clientside functions or amendments to existing functions (for instance, new encryption algorithms) that you feel people may benefit from and don't mind sharing, send me them in a forum PM and I'll check them over. If suitable, they might find themselves in this function pack. :) Similarly if you have any ideas, suggestions or bug reports, just let me know or post them here. Functions shared.getfontzoom(size) (contributed by Xzirox) Returns the font zoom depending upon the text size that is set in the player's F3 options. shared.hextorgb(string) (contributed by Tig) Converts the RGB-format hex string into an array of {red, green, blue} values. For instance, "#FF0000" comes out as {1, 0, 0}. PHP Code:
Converts the RGB into an RGB-format hex string. Essentially the reverse of the above function. PHP Code:
Encrypts the string with the given key. There are two algorithms available: ENC_SIMPLE and ENC_SIMPLE_NOBASE64. The first is basically the simple encryption algorithm that I posted a while ago, while the second is the same algorithm but without the base64 conversion (so you get less overhead but stranger output characters at times). PHP Code:
Decrypts in exactly the same way that the encryption function above works. Provide the encrypted data as the "string", and use the same key to decrypt. PHP Code:
Sets the player's chat text using the privileged setchat function. This means that the chat text works exactly like the chatbar. It interprets things like "showscriptstats" but is set to strip out toalls and toguilds. PHP Code:
Provides the missing trigonometry tan() function. shared.getimgcenter(image name) Returns an array of {x, y} where the X and Y values correspond to the center of the image relative from the top left of the image. PHP Code:
Returns a friendly way of referring to the player on-screen. Guest users will see "Guest User", otherwise the community name/account name are returned instead. shared.pmswaiting() Returns an array of player objects from whom there is a PM waiting to be read. This includes external players from other servers. PHP Code:
Rounds the value to the given number of places. PHP Code:
shared.stringmerge(string, chars[]) Returns a reformatted string stripping whitespaces and any other single characters provided in the chars array. PHP Code:
Sets globally scoped variables clientside for showstats to replace 0x? values for easier script comprehension (STATS_ASD, STATS_ICONS, STATS_RUPEES, STATS_BOMBS, STATS_ARROWS, STATS_HEARTS, STATS_AP, STATS_MP, STATS_MINIMAP, STATS_INVENTORYNPCS, STATS_PLAYERS, STATS_RIGHTCLICK_PROFILE). PHP Code:
shared.setconstants_enablefeatures() Sets globally scoped variables clientside for enablefeatures to replace 0x? values for easier script comprehension (EF_KEY_M, EF_KEY_P, EF_KEY_Q, EF_KEY_R, EF_KEY_SA, EF_KEY_SD, EF_KEY_TAB, EF_CHATTEXT, EF_HEARTSDISPLAY, EF_NICKNAMES, EF_MINIMAP_PMICONS, EF_RIGHTCLICK_PROFILE, EF_EMOTICONS, EF_KEY_ALT5, EF_KEY_ALT89, EF_F2OUTPUT). PHP Code:
Functions as of 20090530 shared.getAlignmentColor(ap) Returns an array of {red, green, blue} for the given AP color, allowing you to recreate the default nickname colors. PHP Code:
Returns an array of {red, green, blue} for the shadow of the given color, allowing you to recreate the default nickname shadows. PHP Code:
Returns a string. Searches string for search and replaces it with replace. shared.getSharedFunctions Returns an array of functions provided by the shared function pack. Function added Jan 05, 2010 shared.adminMessage(text) Opens an admin message window that will stay on the player's screen even after serverwarping until the player closes the window. See: http://forums.graalonline.com/forums...98#post1548498 PHP Code:
|
Awesome. Thank you for this (shared.chat)!
|
Good stuff.
|
getfontzoom <3
|
Thank you!
I've been looking for this kind of (native) support for a long time. Perhaps you could also implement some of the functions in our (Chompy and I) thread: http://forums.graalonline.com/forums...ad.php?t=79473 |
I love you. I need somebody to spread rep, I want to rep Skyld for 3 times now D:
|
Very nice! Thank you, Skyld!
Quote:
|
Quote:
Quote:
|
neato!
|
Quote:
|
Skyld, Stefan, I applaud you. And I applaud those who contributed functions. :p
|
Might take a look at this? :p http://forums.graalonline.com/forums...ad.php?t=79594
It's an encryption algorithm I made some months ago And, really nice Skyld :] Can't wait for more functions to be added |
So why isn't it on login server yet?
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Okay, these functions are now available on the main login server, for all players and servers. :)
|
I just fell in love / fainted / any other word here. YAY! <3
|
Added shared.getAlignmentColor(int ap); and shared.getAlignmentShadowColor(int red, int green, int blue); by request, both returning an array of {red, green, blue}.
|
Could you perhaps add my replacetext function(or a better one, as long as one is available)?
http://forums.graalonline.com/forums...ad.php?t=82820 |
Quote:
Also added a function called shared.getSharedFunctions() which returns an array of public functions provided by the shared function pack. |
Awesome Skyld, thank you!
|
Quote:
Quote:
|
Could you also add this?
PHP Code:
Would return an array of all tiles within the 'blocl' given. I get tired of having to run loops all the time to check a block of tiles. |
The AP shadow function returns 0,0,0 for gold ap, which isn't right.
It should have a check: if (params[0] == 224 && params[1] == 196 && params[2] == 0) return {255,255,0}; Or something like that. |
Couldn't hurt..
PHP Code:
|
1 Attachment(s)
Added a new clientside function, you can access it like so:
PHP Code:
Attached a screenshot of it so you know what it's doing. Basically, it'll open a window (like so) that will remain open even when changing servers, so, for example, if you wanted to open a window before you serverwarp() someone, it's possible now, and they will see the message even when they're on the login server. |
Yes please?
PHP Code:
Also, with these functions are variable names an issue? For example, if I use shared.repeat(" ",5) in a loop that also uses temp.i, is it going to break? |
Quote:
|
Quote:
|
Hey, I'm getting an error sometimes that 'shared.roundto()' not found. Any thought as to why?
|
Quote:
|
Quote:
|
sorry for this... but bump, why do I sometimes get this error?
|
You could try referencing the weapon directly: (@"-Shared").roundto()
Then maybe just make a copy of the function so your code looks a little neater: PHP Code:
|
Quote:
It turns out that Classic's method was roughly twice as fast as the shared function, though some (wouldn't rule out all) of this time may have been down to the fact that public functions take a little bit longer. Me/WhiteDragon then decided to try storing all of the values within an array like this: PHP Code:
|
does shared.getAlignmentShadowColor(r, g, b) even work? What are the expected values? A float 0-1 or an int 0-255?
I have tried PHP Code:
The few times I've gotten it to return something besides that (by first methodology), it returns something entirely wrong, like {0, 0, 255} should the player's AP be 90 (which appears to be a white outline, while the returned is just blue) seems as if both of these functions need work, I'm not sure why different params are passed to one versus the other anyway |
What's wrong with rgbtohex()? shared.rgbtohex(1, 0, 0) returns #0F0000 for me; should be #FF0000 instead. Also, how come rgbtohex() and hextorgb() seem to return more than they should using v6? I always get stuff like "#0F0000 1 0 1" as a return value.
|
Quote:
|
| All times are GMT +2. The time now is 06:12 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.