Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-17-2008, 12:56 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Arrow 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:
shared.hextorgb("#FA32BF"); 
shared.rgbtohex(red, green, blue) (contributed by Tig)
Converts the RGB into an RGB-format hex string. Essentially the reverse of the above function.
PHP Code:
shared.rgbtohex(10.40.7); 
shared.encrypt(algorithm, string, key)
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:
temp.encrypted shared.encrypt(ENC_SIMPLE"test""foo"); 
shared.decrypt(algorithm, string, key)
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:
temp.encrypted shared.encrypt(ENC_SIMPLE"test""foo");
temp.decrypted shared.decrypt(ENC_SIMPLEtemp.encrypted"foo"); 
shared.chat(chat text)
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:
shared.chat("showscriptstats"); 
shared.tan(a)
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:
shared.getimgcenter("block.png"); 
shared.getdisplayname()
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:
for (temp.plshared.pmswaiting())
{
  
//

shared.roundto(value, places)
Rounds the value to the given number of places.
PHP Code:
shared.roundto(3.140.1); 
Functions as of 20080826

shared.stringmerge(string, chars[])
Returns a reformatted string stripping whitespaces and any other single characters provided in the chars array.
PHP Code:
shared.stringmerge("One, two!", {",""!"}); 
shared.setconstants_showstats()
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_showstats();
showstats(allstats STATS_BOMBS STATS_ARROWS); 
A script only needs to run shared.setconstants_showstats() once on the clientside for this to be effective.

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:
shared.setconstants_enablefeatures();
enablefeatures(allfeatures EF_CHATTEXT EF_NICKNAMES); 
A script only needs to run shared.setconstants_enablefeatures() once on the clientside for this to be effective.

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:
shared.getAlignmentColor(player.ap); 
shared.getAlignmentShadowColor(red, green, blue)
Returns an array of {red, green, blue} for the shadow of the given color, allowing you to recreate the default nickname shadows.
PHP Code:
shared.getAlignmentShadowColor(0.750.10.3); 
shared.replacetext(string, search, replace) (contributed by Dusty)
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:
shared.adminMessage("You have been disconnected by Tig"); 

Last edited by Tigairius; 01-06-2010 at 02:43 AM..
Reply With Quote
  #2  
Old 08-17-2008, 01:05 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Awesome. Thank you for this (shared.chat)!
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 08-17-2008, 02:00 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Very nice! Thank you, Skyld!

Quote:
Originally Posted by Tigairius View Post
Awesome. Thank you for this (shared.chat)!
I agree, though Stefan finally added a setChat(chat) function to -Serverlist.
__________________
Reply With Quote
  #4  
Old 08-17-2008, 02:03 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by cbk1994 View Post
I agree, though Stefan finally added a setChat(chat) function to -Serverlist.
Not sure whether this will stay (or whether it'll just be changed to call shared.chat()) since I don't think the serverlist is doing as many checks with it for security.
Quote:
Originally Posted by Programmer
Perhaps you could also implement some of the functions in our (Chompy and I) thread: http://forums.graalonline.com/forums...ad.php?t=79473
Sure can look at it.
Reply With Quote
  #5  
Old 08-17-2008, 02:34 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Skyld View Post
Not sure whether this will stay (or whether it'll just be changed to call shared.chat()) since I don't think the serverlist is doing as many checks with it for security.
I'll change it on Vesporia (am glad I decided to put it in the player class as opposed to calling it each time!)
__________________
Reply With Quote
  #6  
Old 08-17-2008, 01:24 AM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Good stuff.
Reply With Quote
  #7  
Old 08-17-2008, 01:34 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
getfontzoom <3
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #8  
Old 08-17-2008, 01:56 AM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
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ᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #9  
Old 08-17-2008, 02:00 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
I love you. I need somebody to spread rep, I want to rep Skyld for 3 times now D:
__________________
Reply With Quote
  #10  
Old 08-18-2008, 05:14 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by Programmer View Post
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 made these ages ago (well, one function that handles all of that optimized for graal), JUST WAITING FOR ACCESS TO THE SHARED FUNCTIONS
__________________
Reply With Quote
  #11  
Old 08-18-2008, 05:16 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Kristi View Post
JUST WAITING FOR ACCESS TO THE SHARED FUNCTIONS
I don't see why Skyld can't upload it for you if they're already made.. ?
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #12  
Old 08-18-2008, 05:19 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by Tigairius View Post
I don't see why Skyld can't upload it for you if they're already made.. ?
That would make my job rather silly
__________________
Reply With Quote
  #13  
Old 08-17-2008, 02:23 AM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
neato!
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #14  
Old 08-17-2008, 02:58 AM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Skyld, Stefan, I applaud you. And I applaud those who contributed functions.
Reply With Quote
  #15  
Old 08-17-2008, 10:23 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Might take a look at this? 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
__________________
Reply With Quote
Reply


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 06:49 AM.


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