Creation/Dev/Script/Client: Difference between revisions

From Graal Bible
No edit summary
 
(103 intermediate revisions by 14 users not shown)
Line 1: Line 1:
=Client Supported Script Features=
[[Category:Scripting Reference]]
<noinclude>=Client Supported Script Features=


==Settings==
==Settings==
* $camera::movementspeed - float
{| border="1" cellpadding="2" width="100%"
* $pref::audio::choosenvoicecodec - integer
| '''Name'''
* $pref::audio::microactivatebyvolume - boolean
| '''Type'''
* $pref::audio::microactivationlevel - integer
| '''Description'''
* $pref::audio::microinputdevice - integer
|-
* $pref::audio::microon - boolean
| $camera::movementspeed
* $pref::audio::microvolumefactor - integer
| float
* $pref::audio::midivolume - integer
|
* $pref::audio::mp3volume - integer
|-
* $pref::audio::radiovolume - integer
| $pref::audio::choosenvoicecodec
* $pref::audio::reversestereo - boolean
| integer
* $pref::audio::sfxvolume - integer
|
* $pref::audio::voicevolume - integer
|-
* $pref::graal::allowglobalpms - boolean
| $pref::audio::microactivatebyvolume
* $pref::graal::automapping - boolean
| boolean
* $pref::graal::defaultfontsize - integer
|
* $pref::graal::dontconnectlevels - boolean
|-
* $pref::graal::dontloadlistheads - boolean
| $pref::audio::microactivationlevel
* $pref::graal::dontsavepasswords - boolean
| integer
* $pref::graal::dontsavepms - boolean
|
* $pref::graal::fixedport - boolean
|-
* $pref::graal::fixedudpport - integer
| $pref::audio::microinputdevice
* $pref::graal::language - string
| integer
* $pref::graal::limitnicknames - boolean
|
* $pref::graal::loadbuddylistfromserver - boolean
|-
* $pref::graal::nicknamelimit - integer
| $pref::audio::microon
* $pref::graal::nomassmessages - boolean
| boolean
* $pref::graal::notoalls - boolean
|
* $pref::graal::noudp - boolean
|-
* $pref::graal::showyourselfonbuddylists - boolean
| $pref::audio::microvolumefactor
* $pref::input::mousesensitivity - float
| integer
* $pref::interior::lockarrays - boolean
|
* $pref::terrain::enabledetails - boolean
|-
* $pref::video::detailfactor - float
| $pref::audio::midivolume
* $pref::video::fogdistance - float
| integer
* $pref::video::fullscreenmode - string
|
* $pref::video::screenshotformat - string
|-
* $pref::video::visibledistance - float
| $pref::audio::mp3volume
* $pref::video::windowmode - string
| integer
* $scenelighting::lightingprogress - float (read only)
|
|-
| $pref::audio::radiovolume
| integer
|
|-
| $pref::audio::reversestereo
| boolean
|
|-
| $pref::audio::sfxvolume
| integer
|
|-
| $pref::audio::voicevolume
| integer
|
|-
| $pref::graal::allowglobalpms
| boolean
|
|-
| $pref::graal::automapping
| boolean
|
|-
| $pref::graal::defaultfontsize
| integer
| Change showtext zoom: $pref::graal::defaultfontsize/24
|-
| $pref::graal::dontconnectlevels
| boolean
|
|-
| $pref::graal::dontloadlistheads
| boolean
|
|-
| $pref::graal::dontsavepasswords
| boolean
|
|-
| $pref::graal::dontsavepms
| boolean
|
|-
| $pref::graal::fixedport
| boolean
|
|-
| $pref::graal::fixedudpport
| integer
|
|-
| $pref::graal::language
| string
|
|-
| $pref::graal::limitnicknames
| boolean
|
|-
| $pref::graal::loadbuddylistfromserver
| boolean
|
|-
| $pref::graal::nicknamelimit
| integer
|
|-
| $pref::graal::nomassmessages
| boolean
|
|-
| $pref::graal::notoalls
| boolean
|
|-
| $pref::graal::noudp
| boolean
|
|-
| $pref::graal::showyourselfonbuddylists
| boolean
|
|-
| $pref::input::mousesensitivity
| float
|
|-
| $pref::interior::lockarrays
| boolean
|
|-
| $pref::terrain::enabledetails
| boolean
|
|-
| $pref::video::detailfactor
| float
|
|-
| $pref::video::fogdistance
| float
|
|-
| $pref::video::fullscreenmode
| string
|
|-
| $pref::video::screenshotformat
| string
|
|-
| $pref::video::visibledistance
| float
|
|-
| $pref::video::windowmode
| string
|
|-
| $scenelighting::lightingprogress
| float (read only)
|
|}


==Variables==
==Variables==
* allfeatures - integer (read only)
{| border="1" cellpadding="2" width="100%"
* allplayerscount - integer (read only)
| '''Name'''
* allstats - integer (read only)
| '''Type'''
* canspin - boolean (read only)
| '''Description'''
* carriesblackstone - boolean (read only)
|-
* carriesbush - boolean (read only)
| allfeatures
* carriesnpc - boolean (read only)
| integer (read only)
* carriessign - boolean (read only)
| for use with enablefeatures(), it's the default unless it is changed.
* carriesstone - boolean (read only)
|-
* carriesvase - boolean (read only)
| allplayerscount
* downloadfile - string (read only)
| integer (read only)
* downloadpos - integer (read only)
| The size of the allplayers array.
* downloadsize - integer (read only)
|-
* editingmission - boolean
| allrenderobjecttypes
* emoticonchar - string (read only)
| integer (read only)
* focusx - float (read only)
|
* focusy - float (read only)
|-
* graalversion - float (read only)
| allstats
* gravity - float
| integer (read only)
* iscarrying - boolean (read only)
| A bitflag of all stats currently enabled
* isfocused - boolean (read only)
|-
* isgraal3d - boolean (read only)
| canspin
* isleader - boolean (read only)
| boolean (read only)
* isonmap - boolean (read only)
| True if the player has spin attack
* lastdownloadfile - string (read only)
|-
* leftmousebutton - boolean (read only)
| carriesblackstone
* levelorgx - float (read only)
| boolean (read only)
* levelorgy - float (read only)
| True if the player is carrying a black stone
* lighteffectsenabled - boolean (read only)
|-
* middlemousebutton - boolean (read only)
| carriesbush
* mousebuttons - integer (read only)
| boolean (read only)
* mousescreenx - integer
| True if the player is carrying a bush
* mousescreeny - integer
|-
* mousewheeldelta - integer (read only)
| carriesnpc
* mousex - float
| boolean (read only)
* mousey - float
| True if the player is carrying an NPC.
* musiclen - integer (read only)
|-
* musicpos - integer (read only)
| carriessign
* rightmousebutton - boolean (read only)
| boolean (read only)
* screenheight - integer (read only)
| True if a player is carrying a sign.
* screenwidth - integer (read only)
|-
* scriptedcontrols - boolean (read only)
| carriesstone
* scriptedplayerlist - boolean (read only)
| boolean (read only)
* selectedlistplayers - object
| True if a player is carrying a stone.
* selectedsword - integer
|-
* selectedweapon - integer
| carriesvase
* servername - string (read only)
| boolean (read only)
* serverstartconnect - string
| True if a player is carrying a vase.
* serverstartparams - string
|-
* shotbybaddy - boolean (read only)
| downloadfile
* shotbyplayer - boolean (read only)
| string (read only)
* showterraingrid - boolean
| Name of the file currently being downloaded
* timevar - integer (read only)
|-
* timevar2 - float (read only)
| downloadpos
* wasshooted - boolean (read only)
| integer (read only)
* waterheight - float
| Amount of download file already downloaded
* weapons - object (read only)
|-
* weaponsenabled - boolean
| downloadsize
* worldclockstopped - boolean
| integer (read only)
* worldhour - integer
| Size of the file being downloaded
* worldminute - float
|-
* worldminutesofday - float
| editingmission
* worldrealsecondsperday - float
| boolean
|
|-
| emoticonchar
| string (read only)
| The letter of the emoticon being displayed by the player
|-
| focusx
| float (read only)
| X coordinate of the center of playing screen in the level, offset -1.5
|-
| focusy
| float (read only)
| Y coordinate of the center of playing screen in the level, offset -2
|-
| graalversion
| float (read only)
| Graal version
|-
| gravity
| float
| Downward acceleration for projectiles ejected with the shoot() function.
|-
| iscarrying
| boolean (read only)
| True if the player is carrying anything
|-
| isfocused
| boolean (read only)
|
|-
| isgraal3d
| boolean (read only)
| True if you are running graal 3D
|-
| isleader
| boolean (read only)
| signifies that the player is the first person in the level
|-
| isonmap
| boolean (read only)
| signifies that the player is on a map
|-
| jpegquality
| integer
|
|-
| lastdownloadfile
| string (read only)
|
|-
| leftmousebutton
| boolean (read only)
| True if the left mouse button is down
|-
| levelorgx
| float (read only)
| The x-value of the levels' origin (may deviate with attachplayertoobj)
|-
| levelorgy
| float (read only)
| The y-value of the levels' origin (may deviate with attachplayertoobj)
|-
| lighteffectsenabled
| boolean (read only)
| signifies that the player has enabled light effects
|-
| weathereffectsenabled
| boolean (read only)
| signifies that the player has enabled weather effects
|-
| particleeffectsenabled
| boolean (read only)
| signifies that the player has enabled particle effects
|-
| middlemousebutton
| boolean (read only)
| True if the middle mouse button is down
|-
| mousebuttons
| integer (read only)
| Counts the amount of mousebuttons pressed
|-
| mousescreenx
| integer
| X coordinate of the mouse on the GUI layer
|-
| mousescreeny
| integer
| Y coordinate of the mouse on the GUI layer
|-
| mousewheeldelta
| integer (read only)
| Amount that the mouse scroll wheel was scrolled [(-) is up, (+) is down]
|-
| mousex
| float
| X coordinate of the mouse on the tile layer
|-
| mousey
| float
| Y coordinate of the mouse on the tile layer
|-
| musiclen
| integer (read only)
| The duration of the playing sound file
|-
| musicpos
| integer (read only)
| The position in the file at which the sound file is
|-
| rightmousebutton
| boolean (read only)
| True if the right mouse button is down
|-
| screenheight
| integer (read only)
| Height of the Graal window
|-
| screenwidth
| integer (read only)
| Width of the Graal window
|-
| scriptedcontrols
| boolean (read only)
|
|-
| scriptedplayerlist
| boolean (read only)
|
|-
| selectedlistplayers
| object
| an array of players highlighted on the playerlist
|-
| selectedsword
| integer
|
|-
| selectedweapon
| integer
| Index of player.weapons that references the player's current weapon
|-
| servername
| string (read only)
| Name of the current server
|-
| serverstartconnect
| string
|
|-
| serverstartparams
| string
|
|-
| shotbybaddy
| boolean (read only)
| True if the player was shot by a baddy
|-
| shotbyplayer
| boolean (read only)
| True if the player was shot by another player
|-
| showterraingrid
| boolean
|
|-
| timevar
| integer (read only)
| A timer which is increased each 5 seconds and is snychronized between server and clients; The timer started exactly on 2001-02-01 at 18:33:34 Paris time (opening of Graal2001); on serverside the unixtime (timevar2) is around 981048814 + timevar*5
|-
| timevar2
| float (read only)
| Unix-time with a very high precision, not synchronized between server and client
|-
| timevar3
| float (read only)
| synchronized time which works on both server- and client-side, precision is milliseconds, only available for Graal3D right now
|-
| wasshooted
| boolean (read only)
|
|-
| waterheight
| float
| The height of water at the player's (x,y) on a terrain
|-
| weapons
| object (read only)
| An array of weapon objects
|-
| weaponsenabled
| boolean
| Are weapons enabled? (Player can trigger onWeaponFired...)
|-
| worldclockstopped
| boolean
|
|-
| worldhour
| integer
|
|-
| worldminute
| float
|
|-
| worldminutesofday
| float
|
|-
| worldrealsecondsperday
| float
|
|}
 
==Variable Prefixes==
{| border="1" cellpadding="2" width="100%"
| '''Prefix'''
| '''Description'''
|-
| object.var
| accesses the variables of the object. The object can be retrieved by using the case-sensitive name of the object or a variable pointing to the object.
|-
| this.var
| variables that belong to the current script object, on the server-side they are saved to file when the object is a database npc
|-
| thiso.var
| refer to the this. variables of the executing npc ('o' stands for original) when you use the with () command: with (findnpc("npc2")) thiso.temp = this.temp; will copy 'this.temp' from npc2 to the current npc
|-
| temp.var
| variables that belong to the current function. They can be used anywhere in the function even when referencing another object. Function parameters are declared as temp variables if they do not have a prefix. Temp variables will be destroyed at the end of the function.
|-
| player.var
| variables of the current player object, when the event was invoked by a player (e.g. playertouchsme), or you do with (findplayer(accountname))
|-
| playero.var
| variables of the original player object, in generally the player who has invoked the event (e.g. playertouchsme)
|-
| client.var
| short for player.client.var, variables that can be changed on server-side and client-side
|-
| clientr.var
| short for player.clientr.var, variables that can only be changed on server-side but can be read on client-side
|-
| server.var
| variables that only exists on server-side and can be accessed by all npcs
|-
| serverr.var
| variables that can only be changed on server-side and is server wide, but can also be read by all clients, so it can be used for storing the state of global activities that need client-side actions like displaying weather; like server. vars they can also be changed with remotecontrol.exe by administrators that have the right to change server. variables
|-
| level.var
| variables of the current level, which is the level the executing npc stands in (on server-side) or the player is in (on client-side)
|}


==Functions==
==Functions==
* aindexof(float, obj) - returns integer
''Note: Currently this doesn't list the functions which are optimized at compile time, see [[Creation/Dev/Script/Starting_Guide#Standard_functions|Starting Guide: Standard functions]] for those.''
* cursoroff()
 
* cursoron()
===Common===
* echo(str text)
* aindexof(float, array) - returns integer, better use array.index(float) instead
* getbasepackage() - returns object
* echo(str text) - prints text in the F2 window (clientside) or RC chat (serverside)
* getdisplaydevicelist() - returns string
* getbasepackage() - returns [[Creation/Dev/Script/Client/TUpdatePackage|TUpdatePackage]] object
* getdownloadedupdatepackagesize() - returns integer
* getdownloadedupdatepackagesize() - returns integer
* getdownloadingpackage() - returns object
* getdownloadingpackage() - returns [[Creation/Dev/Script/Client/TUpdatePackage|TUpdatePackage]] object
* getdownloadingpackagescount() - returns integer
* getdownloadingpackagescount() - returns integer
* gethttprequest(str, int, str) - returns [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]] object
* gethttprequest(str, int, str) - returns [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]] object
Line 123: Line 502:
* getpackagesdownloaded() - returns boolean
* getpackagesdownloaded() - returns boolean
* getplatform() - returns string
* getplatform() - returns string
* getresolutionlist(str) - returns string
* getservername() - returns string
* getservername() - returns string
* gettotalupdatepackagesize() - returns integer
* gettotalupdatepackagesize() - returns integer
* getupdatepackage(str) - returns object
* getupdatepackage(str) - returns object
* isadminguild(str guildname) - returns boolean
* isadminguild(str guildname) - returns boolean
* iscursoron() - returns boolean
* isobject(str objectname) - returns boolean, checks if an object is existing
* isdevicefullscreenonly(str devicename) - returns boolean
* keydown(int keynumber) - returns if the specified key is pressed (0..10: up, left, down, right, S, A, D, M, tab, Q, P)
* isobject(str objectname) - returns boolean
* keydown(int keycode) - returns boolean
* keydown2(int keycode, bool ignorecase) - returns boolean
* keydown2(int keycode, bool ignorecase) - returns boolean
* keyname(int keycode) - returns string
* keyname(int keycode) - returns string
* opengraalurl(str url)
* opengraalurl(str url) - opens a website of www.graalonline.com and automatically lets the player login to it (e.g. for the upgrade page or screenshot section)
* openurl(str url)
* openurl(str url)
* openurl2(str url, int width, int height)
* openurl2(str url, int width, int height) - deprecated, width and height are ignored
* requesthttp(str, int, str) - returns [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]] object
* requesthttp(str, int, str) - returns [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]] object
* requestmysql(str, str, str, str, str) - returns object
* requesttext(str type, str option)
* requesttext(str, str)
* requesturl(str url) - returns [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]] object
* requesturl(str url) - returns [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]] object
* savelog(str text)
* savelog(str text)
* sendrpgmessage(str text)
* savelog2(str filename, str text) - adds a log entry to "logs/filename"
* sendtext(str, str, params...)
* sendrpgmessage(str text) - adds text to the F2 window
* sendtorc(str text)
* sendtext(str type, str option, params...)
* serverwarp(str serverunixname)
* sendtorc(str text) - serverside only, displays text on the RC chat
* setcursor2(str imagefilename)
* serverwarp(str servername) - the name can either be the internal name (graal2002) or part of the server name on the serverlist
* synctimeofday(float, float)


===Common===
====Files====
====Files====
* extractfilebase(str filepath) - returns string
* extractfilebase(str filepath) - returns string, '/an/example/path/and/file' would return '/an/example/path/and/'
* extractfileext(str filepath) - returns string
* extractfileext(str filepath) - returns string, 'filename.ext' would return '.ext'
* extractfilename(str filepath) - returns string
* extractfilename(str filepath) - returns string, '/an/example/path/and/file' would return 'file'
* extractfilepath(str filepath) - returns string
* extractfilepath(str filepath) - returns string, '/an/example/path/and/file' would return '/an/example/path/and/'
* fileexists(str filepath) - returns boolean
* fileexists(str filepath) - returns boolean, checks if a file exists
* filesize(str filepath) - returns integer
* filesize(str filepath) - returns integer, returns the size of a file
* fileupdate(str filepath) - returns boolean
* fileupdate(str filepath) - returns boolean, checks if a file is existing and requests an update from the server if it has not been checked yet
* findfiles(str, int) - returns object
* findfiles(str filenamepattern, flags) - returns array of strings, flags can be either 1 for recursive search or 0 for non-recursive
* findfirstfile(str) - returns string
* freefileresources(str)
* findnextfile(str) - returns string
* getextension(str filepath) - returns string, 'filename.ext' would return '.ext'
* getextension(str filepath) - returns string
* requestfiledeletion(str filepath), requests a file to be deleted on the server
* reloadfile(str filepath)
* requestfilerename(str filepath, str newfilepath), requests a file to be renamed on the server
* requestfiledeletion(str filepath)
* requestfilesmove(str filepath, str newfilepath), requests a file to be moved on the server
* requestfilerename(str filepath, str newfilepath)
* requestfilesmove(str filepath, str newfilepath)
* selectfilefordownload(str filter)
* selectfilefordownload(str filter)
* selectfileforupload()
* selectfileforupload()
''Watch the [[Creation/Dev/Script/Client/TGraalVar|TGraalVar]] object for loading and saving of files (loadlines etc.)''
''See more information about input/output at [[Creation/Dev/Output Methods|Output methods]]''


====Math====
====Math====
Line 174: Line 549:


=====Matrices=====
=====Matrices=====
* matrixcreate(str, str) - returns string
GraalScript [[Matrix|matricies]] are arrays of seven elements: three describing translation (position), three describing the rotation axis, and one describing the angle.
* matrixcreatefromeuler(str) - returns string
* [[Matrix#matrixcreate()|matrixcreate]](str vector, str rotation) - returns matrix string
* matrixcreatefromeuler(str eulerrotation) - returns matrix string
* matrixmulpoint(str, str) - returns string
* matrixmulpoint(str, str) - returns string
* matrixmultiply(str, str) - returns string
* matrixmultiply(str matrix, str matrix) - returns matrix string
* matrixmulvector(str, str) - returns string
* matrixmulvector(str matrix, str vector) - returns vector string


=====Vectors=====
=====Vectors=====
* vectoradd(str, str) - returns string
Each [[Vectors|vector]] is basicly an array of format {x,y,z} but is passed as string for simplicity. Click on the function names to see more information about the vector operations.
* vectorcross(str, str) - returns string
* [[Vectors#Vector_Addition|vectoradd]](vector, vector) - returns vector
* vectordist(str, str) - returns float
* [[Cross Product|vectorcross]](vector, vector) - returns vector
* vectordot(str, str) - returns float
* [[Vectors#Distance_Between_Terminal_Points|vectordist]](vector, vector) - returns float
* vectorlen(str) - returns float
* [[Dot Product|vectordot]](vector, vector) - returns float
* vectornormalize(str) - returns string
* [[Vectors#Vector_Length_.28Magnitude.29|vectorlen]](vector) - returns float
* vectororthobasis(str) - returns string
* [[Vectors#Unit_Length|vectornormalize]](vector) - returns vector, scales the vector to length 1
* vectorscale(str, float) - returns string
* vectororthobasis(vector) - returns vector
* vectorsub(str, str) - returns string
* [[Vectors#Vector-Scalar_Multiplication|vectorscale]](vector, float) - returns vector
* [[Vectors#Vector_Subtraction|vectorsub]](vector, vector) - returns vector


====Strings====
====Strings====
* base64decode(str text) - returns string
* base64decode(str text) - returns decoded string
* base64encode(str text) - returns string
* base64encode(str text) - returns encoded string
* checksum(str text) - returns float
* checksum(str text) - returns checksum (integer)
* contains(str haystack, str needle) - returns boolean
* contains(str haystack, str needle) - returns boolean, you should probably do haystack.contains(needle) instead
* getascii(str character) - returns integer
* getascii(str character) - returns ASCII value integer
* getstringkeys(str) - returns object
* getstringkeys(str leading) - searches for variables which start with the specified string and returns an array of their endings
* lowercase(str text) - returns string
* lowercase(str text) - returns lowercased string, it is recommended to use string.lower() though
* md5(str tet) - returns string
* md5(str text) - returns md5 hash string
* randomstring(str) - returns string
* randomstring(array of strings) - returns string
* strcmp(str text1, str text2) - returns integer
* strcmp(str text1, str text2) - returns integer (0 if the strings are equal, a negative value if text1 is alphabetically before text2, otherwise a postive value)
* strequals(str text1, str text2) - returns boolean
* strequals(str text1, str text2) - returns boolean, you probably should do text1.equals(text2) or simply text1==text2 instead
* uppercase(str text) - returns string
* uppercase(str text) - returns uppercased string, it is recommended to use string.upper() though


===GUI===
===GUI===
* addcontrol(obj)
* addcontrol(obj) - adds a GUI control or a 3D-object to the scene
* popdialog()
* cursoroff()
* pushdialog(obj)
* cursoron()
* setcontentcontrol(obj)
* iscursoron() - returns boolean
* popdialog() - removes the top dialog control
* pushdialog(obj) - displays a control on top of all other controls, this control gains all focus until it is removed again
* setcontentcontrol(obj) - replaces the current content control (usually named GUIContainer) with another one


===Graal 2D===
===Graal 2D===
* addtiledef(str prefix, str tilesetimage, int tilesettype)
{| border="1" cellpadding="2" width="100%"
* addtiledef2(str prefix, str tilesetimage, int x, int y)
| '''Name'''
* attachplayertoobj(int x, int y)
| '''Type'''
* callnpc(int npcindex, params...)
| '''Description'''
* callweapon(int weaponindex, params...)
|-
* commandtoserver(str text)
| addtiledef(str tilesetimage, str prefix, int tilesettype)
* detachplayer()
|
* disabledefmovement()
| Sets the tileset image for levels beginning with the specified prefix.
* disablemap()
Tileset type 0 is for pics1.png style tilesets.
* disablepause()
Tileset type 1 is for the new tileset format (Era's tiles for example)
* disableselectweapons()
|-
* disableweapons()
| addtiledef2(str tilesetimage, str prefix, int x, int y)
* enabledefmovement()
|
* enablefeatures(int flags)
| Replaces a section of the tileset (x, y) image for levels beginning with the specified prefix.
* enablemap()
|-
* enablepause()
| attachplayertoobj(int objtype, int id)
* enableselectweapons()
|
* enableweapons()
| Attaches a player to the specified object. Using attachpayertoobj(0, id); the player will be attached to the current NPC.
* explodebomb(int bombindex)
|-
* findani(str) - returns object
| callnpc(int npcindex, params...)
* findlevel(str levelfilename) - returns object
|
* findplayer(str accountname) - returns object
| Invokes an event on an npc, better use npcs[npcindex].trigger(event, params) instead; you can only trigger objects this way that are on your side of clientside/serverside
* findplayerbyid(int playerid) - returns object
|-
* findweapon(str weaponname) - returns object
| callweapon(int weaponindex, params...)
* freezeplayer(float seconds)
|
* getimgheight(str imagefilename) - returns integer
| Invokes a trigger on a weapon, better use weapons[weaponindex].trigger(event, params) instead
* getimgwidth(str imagefilename) - returns integer
|-
* getmapx(str levelname) - returns integer
| detachplayer()
* getmapy(str levelname) - returns integer
|
* gettextheight(float, str, str) - returns integer
| Puts the player back on the level (after using attachplayertoobj).
* gettextwidth(float, str, str, str) - returns integer
|-
* getz(float x, float y) - returns float
| disabledefmovement()
* hideplayer(float seconds)
|
* hidesword(float seconds)
| Disables the default movement.
* hitnpc(int, float, float, float)
|-
* hitobjects(float, float, float)
| disablemap()
* hitplayer(int, float, float, float)
|
* lay2(str extraname, float x, float y)
| Disables the default map
* loadmap(str mapfilename)
|-
* noplayerkilling()
| disablepause()
* onwall(float x, float y) - returns boolean
|
* onwall2(float x, float y, float width, float height) - returns boolean
| Disables pausing.
* onwater(float x, float y) - returns boolean
|-
* onwater2(float x, float y, float width, float height) - returns boolean
| disableselectweapons()
* play(str soundfilename)
|
* play2(str, float, float, float)
| Disables the default Q menu.
* playlooped(str soundfilename)
|-
* putleaps(int leapstype, float x, float y)
| disableweapons()
* removetiledefs(str prefix)
|
* replaceani(str defaultaniname, str newaniname)
| Disables weapons.
* resetfocus()
|-
* say(int signindex)
| enabledefmovement()
* say2(str text)
|
* screenx(float x, float y) - returns integer
| Enables default movement
* screeny(float x, float y) - returns integer
|-
* setani(str aniname, str aniparams)
| enablefeatures(int flags)
* setbeltcolor(str color)
|
* setcoatcolor(str color)
| Enable/disable client features
* seteffect(float r, float g, float b, float a)
 
* setfocus(float x, float y)
Flags can consist of:
* setgender(str gendername)
  {| border="1" cellpadding="2" width="100%"
* sethead(str imagefilename)
  | '''Value'''
* setletters(str imagefilename)
  | '''Description'''
* setmap(str, str, float, float)
  |-
* setminimap(str, str, float, float)
  | 1
* setmusicvolume(float, float)
  | M key (map)
* setplayerdir(str)
  |-
* setshield(str imagefilename, int shieldpower)
  | 2
* setshoecolor(str color)
  | P key (pause)
* setshootparams(str params)
  |-
* setskincolor(str color)
  | 4
* setsleevecolor(str color)
  | Q key (weapon select)
* setsword(str imagefilename, int swordpower)
  |-
* showstats(int statsflag)
  | 8
* spyfire(int x, int y)
  | R key (show ratings)
* stopmidi()
  |-
* stopsound(str soundfilename)
  | 0x10
* takeplayercarry()
  | S+A key combination for dropping items
* takeplayerhorse()
  |-
* testplayer(float x, float y) - returns integer
  | 0x20
* triggeraction(float x, float y, str dest, params...)
  | S+D key combination for switching weapons
* triggerserver(str dest, str params)
  |-
* updateboard(int x, int y, int width, int height)
  | 0x40
* updateratings(obj) - returns object - updates an array of {rating1,ratingdeviation1, rating2,ratingdeviation2, ...}, init them at 1500 and 350
  | TAB key (if disabled then you cannot switch to the chat field with TAB)
* worldx(float x, float y) - returns float
  |-
* worldy(float x, float y) - returns float
  | 0x80
* wraptext(int fontsize, str format, str text) - returns object
  | Display of chat text
* wraptext2(int, float, str, str) - returns object
  |-
  | 0x100
  | Display of the hearts over player heads
  |-
  | 0x200
  | Display of nicknames
  |-
  | 0x400
  | Toall/PM-icons on the minimap
  |-
  | 0x800
  | Right-click on players opens their profile
  |-
  | 0x1000
  | Emoticons (disable it if you want to do other stuff with control+keys)
  |-
  | 0x2000
  | Alt+5 for making snapshots  ''(deprecated)''
  |-
  | 0x4000
  | Alt+8/9 for zooming ''(deprecated)''
  |-
  | 0x8000
  | Allows F2 output (savelog()/echo())
  |-
  | allfeatures
  | All of the previously stated feature flags enabled
  |}
|-
| enablemap()
|
| Enables default map.
|-
| enablepause()
|
| Enables pausing.
|-
| enableselectweapons()
|
| Enables default Q menu.
|-
| enableweapons()
|
| Enables weapons.
|-
| explodebomb(int bombindex)
|
| Explodes a bomb with the specified index.
|-
| findani(str)
| [[Creation/Dev/Script/Client/TGraalAni|TGraalAni]] object
|
|-
| findlevel(str levelfilename)
| [[Creation/Dev/Script/Client/TServerLevel|TServerLevel]] object
|
|-
| findplayer(str accountname)
| [[Creation/Dev/Script/Client/TServerPlayer|TServerPlayer]] object
| Returns player object of Account specified. Player must be online.
|-
| findplayerbyid(int playerid)
| [[Creation/Dev/Script/Client/TServerPlayer|TServerPlayer]] object
| Returns player object of id specified. If id isn't available, returns false.
|-
| findweapon(str weaponname)
| [[Creation/Dev/Script/Client/TServerWeapon|TServerWeapon]] object
| Returns weapon object of the specified name if the player has that weapon.
|-
| findweaponnpc(str weaponname)
| [[Creation/Dev/Script/Client/TServerWeapon|TServerWeapon]] object
| Returns weapon object if it exits on the server, only works on server-side. You can normally also access weapons by just typing their name though (e.g. MyWeapon.functionname() instead of findweaponnpc("MyWeapon").functionname())
|-
| freezeplayer(float seconds)
|
| Freezes player for a specific amount of time.
|-
| getimgheight(str imagefilename)
| integer
| Returns the height (in pixels) of an image.
|-
| getimgwidth(str imagefilename)
| integer
| Returns the width (in pixels) of an image.
|-
| getmapx(str levelname)
| integer
| X coordinate of the level on a map (top-left level is 0)
|-
| getmapy(str levelname)
| integer
| Y coordinate of the level on a map (top-left level is 0)
|-
| gettextheight(float, str, str)
| integer
| Returns the height of the font. Format:
  gettextheight(zoom, font, style)
|-
| gettextwidth(float, str, str, str)
| integer
| Returns the width of a specified text in a certain font. Format:
  gettextwidth(zoom, font, style, text)
|-
| getz(float x, float y)
| float
| Returns the z value of a terrain at (x,y).
|-
| graalcontrolhasfocus(bool)
| boolean
| parameter says if it should also check if the chat bar has the focus
|-
| hideplayer(float seconds)
|
| Hides the player for ''seconds'' seconds.
|-
| hidesword(float seconds)
|
| Hides the player's sword for ''seconds'' seconds.
|-
| hitnpc(int, float, float, float)
|
|
|-
| hitobjects(float, float, float)
|
|
|-
| hitplayer(int, float, float, float)
|
|
|-
| lay2(str extraname, float x, float y)
|
|
|-
| loadmap(str mapfilename)
|
| Preloads a gmap on clientside, speeds up entering of new maps but is not required.
|-
| noplayerkilling()
|
| Disables killing of other players. This also lets players walk through other players (players are not blocking anymore).
|-
| onwall(float x, float y)
| boolean
| Returns true if the specified x and y is a blocking tile.
|-
| onwall2(float x, float y, float width, float height)
| boolean
| Returns true if a blocking tile exists in the specified area.
|-
| onwater(float x, float y)
| boolean
| Returns true if the specified x and y is water.
|-
| onwater2(float x, float y, float width, float height)
| boolean
| Returns true if water exists in the specified area.
|-
| play(str soundfilename)
|
| Plays the specified sound file.
|-
| play2(str soundfilename, float x, float y, float volume)
|
| Plays the specified sound file at location x, y with the specified volume. Volume should be between 0 and 1, if volume is set to 1 default volume is used (depending on how far away the player is).
|-
| playlooped(str soundfilename)
|
| Plays the specified sound file in a loop until stopsound() is called.
|-
| playlooped2(str soundfile, float x, float y, float volume)
|
| Plays the specified sound file at location x, y with the specified volume in a loop until stopsound() is called. Volume should be between 0 and 1, if volume is set to 1 default volume is used (depending on how far away the player is).
|-
| putleaps(int leapstype, float x, float y)
|
|
|-
| removetiledefs(str prefix)
|
| Remove tile definitions set by addtiledef and addtiledef2 for the specified prefix.
|-
| replaceani(str defaultaniname, str newaniname)
|
| replaces the player's default ani with the new ani.
|-
| resetfocus()
|
| Sets the screen focus to the player (default focus behaviour).
|-
| say(int signindex)
|
|
|-
| say2(str text)
|
|
|-
| screenx(float x, float y)
| integer
| returns the x of the screen layer for a location on the tiles layer.
|-
| screeny(float x, float y)
| integer
| returns the y of the screen layer for a location on the tiles layer.
|-
| worldx(float x, float y)
| float
| returns the x of the tiles layer for a location on the screen layer.
|-
| worldy(float x, float y)
| float
| returns the y of the tiles layer for a location on the screen layer.
|-
| setani(str aniname, str aniparams)
|
| Sets the gani of a player.
|-
| setbeltcolor(str color)
|
|
|-
| setcoatcolor(str color)
|
|
|-
| seteffect(float red, float green, float blue, float alpha)
|
| Displays a 'day-night' effect on top of the game. Default value is (0,0,0,0). Change alpha to make the screen darker. You can reach the same effect if you use a polygon (showpoly()) and set the mode to 3. To manipulate the color of a single npc, see setcoloreffect() for [[Creation/Dev/Script/Client/TServerNPC|TServerNPC]].
|-
| setfocus(float x, float y)
|
| Sets the screen focus to the specified x and y. Use resetfocus() to switch back to the default focus behaviour.
|-
| setgender(str gendername)
|
| Sets the gender of a player.
|-
| sethead(str imagefilename)
|
| Sets the head of a player
|-
| setletters(str imagefilename)
|
| Sets the image to use for sign background and text.
|-
| setmap(str textfile, str image, float defaultx, float defaultx)
|
| Sets a text map (you can see the tiles of other levels but not the npcs), use gmaps if possible instead of this; the parameter order has been changed between GS1 and GS2 to match the server option "bigmap="
|-
| setminimap(str textfile, str image, float defaultx, float defaulty)
|
| Sets the mini map, use gmaps if possible instead of this; the parameter order has been changed between GS1 and GS2 to match the server option "minimap="
|-
| setmusicvolume(float, float)
|
|
|-
| setplayerdir(str)
|
|
|-
| setshield(str imagefilename, int shieldpower)
|
|
|-
| setshoecolor(str color)
|
|
|-
| setshootparams(str params)
|
|
|-
| setskincolor(str color)
|
|
|-
| setsleevecolor(str color)
|
|
|-
| setsword(str imagefilename, int swordpower)
|
|
|-
| showstats(int statsflag)
|
| With this you can show/hide parts of the status bar / game
 
Examples:
<pre>
// Shows all
showstats(allstats);
 
// Enable everything except minimap
showstats(allstats & ~0x100);
 
// Enable everything except AP and MP bars
showstats(allstats & ~(0x40 | 0x80));
 
// Enable only players and right-click profile
showstats(0x400 | 0x800);
 
// Hides all
showstats(0);
</pre>
 
Flags can consist of:
  {| border="1" cellpadding="2" width="100%"
  | '''Value'''
  | '''Description'''
  |-
  | 1
  | ASD
  |-
  | 2
  | Icons (for rupees, bombs, arrows)
  |-
  | 4
  | Rupees count
  |-
  | 8
  | Bombs count
  |-
  | 0x10
  | Arrows count
  |-
  | 0x20
  | Hearts
  |-
  | 0x40
  | Alignment (ap) bar
  |-
  | 0x80
  | Magic points (mp) bar
  |-
  | 0x100
  | Minimap (you can only hide it, you can't show it when the player pressed Alt+3)
  |-
  | 0x200
  | Inventory NPCs
  |-
  | 0x400
  | Players
  |-
  | 0x800
  | Right-click on players opens their profile
  |-
  | allstats
  | All of the previously stated stats flags enabled
  |}
|-
| spyfire(int length, int power)
|
| Shoots a line of fire in the direction of the player with the specified tile length, and fire power (1 - bomb, 2 - super bomb, 3 - jolt bomb).
|-
| stopmidi()
|
|
|-
| stopsound(str soundfilename)
|
| Stop playing a sound started by playlooped
|-
| takeplayercarry()
|
|
|-
| takeplayerhorse()
|
|
|-
| testplayer(float x, float y)
| integer
| checks if there is a player on that position and returns the index of the player in players[], or -1 if there is none
|-
| triggeraction(float x, float y, str eventname, params...)
|
| Invokes an "onActionEventname" event on objects at the specified position, can be used to invoke events on objects from clientside to serverside and vice versa.
Special eventnames are "serverEventname" which will invoke an event on the Control-NPC (onActionEventname), or "serverside" which will invoke an onActionServerSide event on the weapon script specified by the first following parameter (the fourth parameter). It is recommended to use triggerserver() for that though.
 
Example:
<pre>
triggeraction(30, 30, "explode", 5);
triggeraction(0, 0, "serverchat", player.chat);
triggeraction(0, 0, "serverside", "PlasmaGun", "activate");
</pre>
|-
| triggerserver(str objecttype, str objectname, str params)
|
| Invokes an event on a serverside object, currently objecttype can only be "gui" or "weapon" (which is the same), objectname is the name of the weapon script, the invoked event will be "onActionServerSide".
On Graal3D the event will be "onActionParam0" instead.
For invoking events on the clientside use player.triggerclient(objecttype,objectname,params) instead.
 
Example:
<pre>
triggerserver("weapon", "PlasmaGun", "activate");
</pre>
|-
| updateboard(int x, int y, int width, int height)
|
|
|-
| updateratings(obj)
| object
| Updates an array of {rating1,ratingdeviation1, rating2,ratingdeviation2, ...}, init them at 1500 and 350.
Example:
<pre>
newratings = updateratings({winner.rating,winner.ratingd,loser.rating,loser.ratingd});
winner.rating = newratings[0];
winner.ratingd = newratings[1];
loser.rating = newratings[2];
loser.ratingd = newratings[3];
</pre>
|-
| wraptext(int fontsize, str format, str text)
| array of strings
|
|-
| wraptext2(int pixelwidth, float zoom, str delimiters, str text)
| array of strings
| wraps the text so that it fits in the specified number of pixels and returns an array of text lines
|}


===Graal 3D===
===Graal 3D===
* addmaterialmapping(str, str) - returns boolean
* getboxcenter(str box) - returns string
* getboxcenter(str) - returns string
* get3dobjectat(float x, float y, bool doboxcollision) - returns object - gets the 3d object at the specified screen position, third parameter says if it should do box collision
* getdatablocktypes() - returns object
* get3dobjectatmouse(bool doboxcollision) - returns object - gets the 3d object at the mouse, specify if it should do box collision (true)
* getobjectat(float, float) - returns object
* get3dobjectbyray(str vector, str vector) - returns object
* getobjectatmouse() - returns object
* getobjectbyray(str, str) - returns object
* getsurfacetype(float, float) - returns string
* lightscene() - returns boolean
* lightscene() - returns boolean
* mapshapeanimation(str, str, str, float) - returns boolean
* setfogcolors(array)
* setfogcolors(obj)
* setinteriorrendermode(int)
* setinteriorrendermode(int)
* setshadowdetaillevel(float)
* setskybandcolors(array)
* setskybandcolors(obj)
* setskybandsizes(array)
* setskybandsizes(obj)
* setsuncolors(array)
* setsuncolors(obj)
* setterrainrendermode(int)
* setterrainrendermode(int)
* synctimeofday(float hour, float minute)
* updateterrain()
* updateterrain()
* updatevisibledistance()
* updatevisibledistance()


===Other===
==Classes / Object Types==</noinclude>
* adventure_installgraal(str, bool, bool)
<includeonly>=Object Navigation=</includeonly>
* adventure_openexternaloptions() - returns boolean
* adventure_openexternalpm(obj) - returns boolean
* adventure_openserverlist()
* adventure_quit()
* adventure_savegraaloptions()
* adventure_selectpath(str) - returns object
* adventure_setaccountname(str)
* adventure_setchat(str)
* adventure_setnickname(str)
* adventure_setpassword(str)
* adventure_startofflinemode()
* adventure_updateaccountfield()
* adventure_updatemicroactivationlevel()
* adventure_updatemidivolume()
* adventure_updatemp3volume()
* adventure_updateplayermuted()
* adventure_updateplayerprofile(bool, str, str, int, str, str, str, str, str, str)
* adventure_updateradiovolume()
 
==Objects==
* [[Creation/Dev/Script/Client/TGraalVar|TGraalVar]]
* [[Creation/Dev/Script/Client/TGraalVar|TGraalVar]]
** [[Creation/Dev/Script/Client/ActionMap|ActionMap]]
** [[Creation/Dev/Script/Client/ActionMap|ActionMap]]
** [[Creation/Dev/Script/Client/DTSAniThread|DTSAniThread]]
** [[Creation/Dev/Script/Client/GameMovementInterpolate|GameMovementInterpolate]]
*** [[Creation/Dev/Script/Client/GameMovementRigid|GameMovementRigid]]
** [[Creation/Dev/Script/Client/GameMovementList|GameMovementList]]
** [[Creation/Dev/Script/Client/GameShape|GameShape]]
*** [[Creation/Dev/Script/Client/GameShape3DS|GameShape3DS]]
*** [[Creation/Dev/Script/Client/GameShapeDIF|GameShapeDIF]]
*** [[Creation/Dev/Script/Client/GameShapeDTS|GameShapeDTS]]
*** [[Creation/Dev/Script/Client/GameShapeFT|GameShapeFT]]
** [[Creation/Dev/Script/Client/GuiControl|GuiControl]]
** [[Creation/Dev/Script/Client/GuiControl|GuiControl]]
*** [[Creation/Dev/Script/Client/EditManager|EditManager]]
*** [[Creation/Dev/Script/Client/GuiArrayCtrl|GuiArrayCtrl]]
*** [[Creation/Dev/Script/Client/GuiArrayCtrl|GuiArrayCtrl]]
**** [[Creation/Dev/Script/Client/GuiTextListCtrl|GuiTextListCtrl]]
**** [[Creation/Dev/Script/Client/GuiTextListCtrl|GuiTextListCtrl]]
**** [[Creation/Dev/Script/Client/GuiTreeViewCtrl|GuiTreeViewCtrl]]
**** [[Creation/Dev/Script/Client/GuiTreeViewCtrl|GuiTreeViewCtrl]]
*** [[Creation/Dev/Script/Client/GuiBackgroundCtrl|GuiBackgroundCtrl]]
*** [[Creation/Dev/Script/Client/GuiBitmapBorderCtrl|GuiBitmapBorderCtrl]]
*** [[Creation/Dev/Script/Client/GuiBitmapButtonCtrl|GuiBitmapButtonCtrl]]
*** [[Creation/Dev/Script/Client/GuiBitmapButtonCtrl|GuiBitmapButtonCtrl]]
*** [[Creation/Dev/Script/Client/GuiBitmapCtrl|GuiBitmapCtrl]]
*** [[Creation/Dev/Script/Client/GuiBitmapCtrl|GuiBitmapCtrl]]
**** [[Creation/Dev/Script/Client/GuiCrossHairHud|GuiCrossHairHud]]
**** [[Creation/Dev/Script/Client/GuiMapOverviewCtrl|GuiMapOverviewCtrl]]
**** [[Creation/Dev/Script/Client/GuiMapOverviewCtrl|GuiMapOverviewCtrl]]
*** [[Creation/Dev/Script/Client/GuiButtonBaseCtrl|GuiButtonBaseCtrl]]
*** [[Creation/Dev/Script/Client/GuiButtonBaseCtrl|GuiButtonBaseCtrl]]
**** [[Creation/Dev/Script/Client/GuiBorderButtonCtrl|GuiBorderButtonCtrl]]
**** [[Creation/Dev/Script/Client/GuiButtonCtrl|GuiButtonCtrl]]
**** [[Creation/Dev/Script/Client/GuiButtonCtrl|GuiButtonCtrl]]
**** [[Creation/Dev/Script/Client/GuiCheckBoxCtrl|GuiCheckBoxCtrl]]
**** [[Creation/Dev/Script/Client/GuiCheckBoxCtrl|GuiCheckBoxCtrl]]
Line 374: Line 1,158:
**** [[Creation/Dev/Script/Client/GuiPMCtrl|GuiPMCtrl]]
**** [[Creation/Dev/Script/Client/GuiPMCtrl|GuiPMCtrl]]
**** [[Creation/Dev/Script/Client/GuiPMHistoryCtrl|GuiPMHistoryCtrl]]
**** [[Creation/Dev/Script/Client/GuiPMHistoryCtrl|GuiPMHistoryCtrl]]
*** [[Creation/Dev/Script/Client/GuiMouseEventCtrl|GuiMouseEventCtrl]]
*** [[Creation/Dev/Script/Client/GuiPlayerView|GuiPlayerView]]
*** [[Creation/Dev/Script/Client/GuiPlayerView|GuiPlayerView]]
*** [[Creation/Dev/Script/Client/GuiProgressCtrl|GuiProgressCtrl]]
*** [[Creation/Dev/Script/Client/GuiProgressCtrl|GuiProgressCtrl]]
Line 381: Line 1,164:
*** [[Creation/Dev/Script/Client/GuiShowImgCtrl|GuiShowImgCtrl]]
*** [[Creation/Dev/Script/Client/GuiShowImgCtrl|GuiShowImgCtrl]]
*** [[Creation/Dev/Script/Client/GuiSliderCtrl|GuiSliderCtrl]]
*** [[Creation/Dev/Script/Client/GuiSliderCtrl|GuiSliderCtrl]]
*** [[Creation/Dev/Script/Client/GuiStretchCtrl|GuiStretchCtrl]]
*** [[Creation/Dev/Script/Client/GuiTabCtrl|GuiTabCtrl]]
*** [[Creation/Dev/Script/Client/GuiTabCtrl|GuiTabCtrl]]
*** [[Creation/Dev/Script/Client/GuiTextCtrl|GuiTextCtrl]]
*** [[Creation/Dev/Script/Client/GuiTextCtrl|GuiTextCtrl]]
**** [[Creation/Dev/Script/Client/GuiBubbleTextCtrl|GuiBubbleTextCtrl]]
**** [[Creation/Dev/Script/Client/GuiPopUpEditCtrl|GuiPopUpEditCtrl]]
**** [[Creation/Dev/Script/Client/GuiPopUpEditCtrl|GuiPopUpEditCtrl]]
**** [[Creation/Dev/Script/Client/GuiPopUpMenuCtrl|GuiPopUpMenuCtrl]]
**** [[Creation/Dev/Script/Client/GuiPopUpMenuCtrl|GuiPopUpMenuCtrl]]
Line 396: Line 1,179:
** [[Creation/Dev/Script/Client/GuiTextListEntry|GuiTextListEntry]]
** [[Creation/Dev/Script/Client/GuiTextListEntry|GuiTextListEntry]]
** [[Creation/Dev/Script/Client/GuiTreeViewNode|GuiTreeViewNode]]
** [[Creation/Dev/Script/Client/GuiTreeViewNode|GuiTreeViewNode]]
** [[Creation/Dev/Script/Client/MissionArea|MissionArea]]
** [[Creation/Dev/Script/Client/MRandomGenerator|MRandomGenerator]]
** [[Creation/Dev/Script/Client/ShapeBaseHitBox|ShapeBaseHitBox]]
*** [[Creation/Dev/Script/Client/MRandomLCG|MRandomLCG]]
** [[Creation/Dev/Script/Client/ShapeImageState|ShapeImageState]]
*** [[Creation/Dev/Script/Client/MRandomR250|MRandomR250]]
** [[Creation/Dev/Script/Client/SimObject|SimObject]]
** [[Creation/Dev/Script/Client/SimObject|SimObject]]
*** [[Creation/Dev/Script/Client/SceneObject|SceneObject]]
*** [[Creation/Dev/Script/Client/SceneObject|SceneObject]]
**** [[Creation/Dev/Script/Client/AudioEmitter|AudioEmitter]]
**** [[Creation/Dev/Script/Client/FractalTree|FractalTree]]
**** [[Creation/Dev/Script/Client/fxFoliageReplicator|fxFoliageReplicator]]
**** [[Creation/Dev/Script/Client/fxGrassReplicator|fxGrassReplicator]]
**** [[Creation/Dev/Script/Client/fxShapeReplicator|fxShapeReplicator]]
**** [[Creation/Dev/Script/Client/fxSunLight|fxSunLight]]
**** [[Creation/Dev/Script/Client/fxSunLight|fxSunLight]]
**** [[Creation/Dev/Script/Client/GameBase|GameBase]]
**** [[Creation/Dev/Script/Client/GameObject|GameObject]]
***** [[Creation/Dev/Script/Client/Camera|Camera]]
***** [[Creation/Dev/Script/Client/DynamicShapeReplicator|DynamicShapeReplicator]]
***** [[Creation/Dev/Script/Client/DynamicShapeReplicator|DynamicShapeReplicator]]
****** [[Creation/Dev/Script/Client/DynamicGrass|DynamicGrass]]
****** [[Creation/Dev/Script/Client/DynamicGrass|DynamicGrass]]
****** [[Creation/Dev/Script/Client/DynamicGrassReplicator|DynamicGrassReplicator]]
****** [[Creation/Dev/Script/Client/DynamicGrassReplicator|DynamicGrassReplicator]]
***** [[Creation/Dev/Script/Client/Explosion|Explosion]]
***** [[Creation/Dev/Script/Client/fxLight|fxLight]]
***** [[Creation/Dev/Script/Client/Lightning|Lightning]]
***** [[Creation/Dev/Script/Client/ParticleEmitter|ParticleEmitter]]
***** [[Creation/Dev/Script/Client/ParticleEmitterNode|ParticleEmitterNode]]
***** [[Creation/Dev/Script/Client/PathedInterior|PathedInterior]]
***** [[Creation/Dev/Script/Client/Precipitation|Precipitation]]
***** [[Creation/Dev/Script/Client/Projectile|Projectile]]
***** [[Creation/Dev/Script/Client/ShapeBase|ShapeBase]]
****** [[Creation/Dev/Script/Client/AdvancedCamera|AdvancedCamera]]
****** [[Creation/Dev/Script/Client/Camera|Camera]]
****** [[Creation/Dev/Script/Client/MissionMarker|MissionMarker]]
****** [[Creation/Dev/Script/Client/PathCamera|PathCamera]]
****** [[Creation/Dev/Script/Client/Player|Player]]
******* [[Creation/Dev/Script/Client/AIPlayer|AIPlayer]]
****** [[Creation/Dev/Script/Client/StaticShape|StaticShape]]
****** [[Creation/Dev/Script/Client/Vehicle|Vehicle]]
******* [[Creation/Dev/Script/Client/FlyingVehicle|FlyingVehicle]]
******* [[Creation/Dev/Script/Client/HoverVehicle|HoverVehicle]]
******* [[Creation/Dev/Script/Client/WheeledVehicle|WheeledVehicle]]
***** [[Creation/Dev/Script/Client/SpawnSphere|SpawnSphere]]
***** [[Creation/Dev/Script/Client/Splash|Splash]]
***** [[Creation/Dev/Script/Client/Trigger|Trigger]]
***** [[Creation/Dev/Script/Client/TSStatic|TSStatic]]
****** [[Creation/Dev/Script/Client/Item|Item]]
**** [[Creation/Dev/Script/Client/InteriorInstance|InteriorInstance]]
**** [[Creation/Dev/Script/Client/Marker|Marker]]
**** [[Creation/Dev/Script/Client/Shape3ds|Shape3ds]]
**** [[Creation/Dev/Script/Client/Sky|Sky]]
**** [[Creation/Dev/Script/Client/Sky|Sky]]
**** [[Creation/Dev/Script/Client/TerrainBlock|TerrainBlock]]
**** [[Creation/Dev/Script/Client/TerrainBlock|TerrainBlock]]
**** [[Creation/Dev/Script/Client/twSurfaceReference|twSurfaceReference]]
**** [[Creation/Dev/Script/Client/twSurfaceReference|twSurfaceReference]]
**** [[Creation/Dev/Script/Client/volumeLight|volumeLight]]
**** [[Creation/Dev/Script/Client/WaterBlock|WaterBlock]]
**** [[Creation/Dev/Script/Client/WaterBlock|WaterBlock]]
*** [[Creation/Dev/Script/Client/SimDataBlock|SimDataBlock]]
**** [[Creation/Dev/Script/Client/AudioDescription|AudioDescription]]
**** [[Creation/Dev/Script/Client/AudioProfile|AudioProfile]]
**** [[Creation/Dev/Script/Client/DecalData|DecalData]]
**** [[Creation/Dev/Script/Client/GameBaseData|GameBaseData]]
***** [[Creation/Dev/Script/Client/DebrisData|DebrisData]]
***** [[Creation/Dev/Script/Client/ExplosionData|ExplosionData]]
***** [[Creation/Dev/Script/Client/fxLightData|fxLightData]]
***** [[Creation/Dev/Script/Client/ItemData|ItemData]]
***** [[Creation/Dev/Script/Client/LightningData|LightningData]]
***** [[Creation/Dev/Script/Client/ParticleEmitterData|ParticleEmitterData]]
***** [[Creation/Dev/Script/Client/ParticleEmitterNodeData|ParticleEmitterNodeData]]
***** [[Creation/Dev/Script/Client/PathedInteriorData|PathedInteriorData]]
***** [[Creation/Dev/Script/Client/PrecipitationData|PrecipitationData]]
***** [[Creation/Dev/Script/Client/ProjectileData|ProjectileData]]
***** [[Creation/Dev/Script/Client/ShapeBaseData|ShapeBaseData]]
****** [[Creation/Dev/Script/Client/AdvancedCameraData|AdvancedCameraData]]
****** [[Creation/Dev/Script/Client/CameraData|CameraData]]
****** [[Creation/Dev/Script/Client/MissionMarkerData|MissionMarkerData]]
****** [[Creation/Dev/Script/Client/PlayerData|PlayerData]]
****** [[Creation/Dev/Script/Client/StaticShapeData|StaticShapeData]]
****** [[Creation/Dev/Script/Client/VehicleData|VehicleData]]
******* [[Creation/Dev/Script/Client/FlyingVehicleData|FlyingVehicleData]]
******* [[Creation/Dev/Script/Client/HoverVehicleData|HoverVehicleData]]
******* [[Creation/Dev/Script/Client/WheeledVehicleData|WheeledVehicleData]]
***** [[Creation/Dev/Script/Client/ShapeBaseImageData|ShapeBaseImageData]]
***** [[Creation/Dev/Script/Client/SplashData|SplashData]]
***** [[Creation/Dev/Script/Client/TriggerData|TriggerData]]
**** [[Creation/Dev/Script/Client/ParticleData|ParticleData]]
**** [[Creation/Dev/Script/Client/TSShapeConstructor|TSShapeConstructor]]
**** [[Creation/Dev/Script/Client/WheeledVehicleSpring|WheeledVehicleSpring]]
**** [[Creation/Dev/Script/Client/WheeledVehicleTire|WheeledVehicleTire]]
*** [[Creation/Dev/Script/Client/SimGroup|SimGroup]]
*** [[Creation/Dev/Script/Client/SimGroup|SimGroup]]
**** [[Creation/Dev/Script/Client/GameConnection|GameConnection]]
**** [[Creation/Dev/Script/Client/GameConnection|GameConnection]]
Line 509: Line 1,227:
** [[Creation/Dev/Script/Client/TGraalSpriteAttachment|TGraalSpriteAttachment]]
** [[Creation/Dev/Script/Client/TGraalSpriteAttachment|TGraalSpriteAttachment]]
** [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]]
** [[Creation/Dev/Script/Client/THTTPRequest|THTTPRequest]]
** [[Creation/Dev/Script/Client/TMovementRigid|TMovementRigid]]
** [[Creation/Dev/Script/Client/TParticle|TParticle]]
** [[Creation/Dev/Script/Client/TParticle|TParticle]]
** [[Creation/Dev/Script/Client/TParticleEmitter|TParticleEmitter]]
** [[Creation/Dev/Script/Client/TParticleEmitter|TParticleEmitter]]
Line 514: Line 1,233:
** [[Creation/Dev/Script/Client/TServerLevel|TServerLevel]]
** [[Creation/Dev/Script/Client/TServerLevel|TServerLevel]]
** [[Creation/Dev/Script/Client/TServerLevelLink|TServerLevelLink]]
** [[Creation/Dev/Script/Client/TServerLevelLink|TServerLevelLink]]
** [[Creation/Dev/Script/Client/TShapeMaterial|TShapeMaterial]]
** [[Creation/Dev/Script/Client/TShowImg_Values|TShowImg_Values]]
** [[Creation/Dev/Script/Client/TShowImg_Values|TShowImg_Values]]
*** [[Creation/Dev/Script/Client/TShowImg_Flash|TShowImg_Flash]]
*** [[Creation/Dev/Script/Client/TShowImg_Gani|TShowImg_Gani]]
*** [[Creation/Dev/Script/Client/TShowImg_Gani|TShowImg_Gani]]
*** [[Creation/Dev/Script/Client/TShowImg_Image|TShowImg_Image]]
*** [[Creation/Dev/Script/Client/TShowImg_Image|TShowImg_Image]]
*** [[Creation/Dev/Script/Client/TShowImg_Shape|TShowImg_Shape]]
*** [[Creation/Dev/Script/Client/TShowImg_Shape|TShowImg_Shape]]
*** [[Creation/Dev/Script/Client/TShowImg_Poly|TShowImg_Poly]]
*** [[Creation/Dev/Script/Client/TShowImg_Text|TShowImg_Text]]
*** [[Creation/Dev/Script/Client/TShowImg_Text|TShowImg_Text]]
** [[Creation/Dev/Script/Client/TShowImgMount|TShowImgMount]]
** [[Creation/Dev/Script/Client/TStaticVar|TStaticVar]]
** [[Creation/Dev/Script/Client/TStaticVar|TStaticVar]]
** [[Creation/Dev/Script/Client/TTilesLayer|TTilesLayer]]
** [[Creation/Dev/Script/Client/TUpdatePackage|TUpdatePackage]]
** [[Creation/Dev/Script/Client/TUpdatePackage|TUpdatePackage]]

Latest revision as of 23:44, 15 February 2010

Client Supported Script Features

Settings

Name Type Description
$camera::movementspeed float
$pref::audio::choosenvoicecodec integer
$pref::audio::microactivatebyvolume boolean
$pref::audio::microactivationlevel integer
$pref::audio::microinputdevice integer
$pref::audio::microon boolean
$pref::audio::microvolumefactor integer
$pref::audio::midivolume integer
$pref::audio::mp3volume integer
$pref::audio::radiovolume integer
$pref::audio::reversestereo boolean
$pref::audio::sfxvolume integer
$pref::audio::voicevolume integer
$pref::graal::allowglobalpms boolean
$pref::graal::automapping boolean
$pref::graal::defaultfontsize integer Change showtext zoom: $pref::graal::defaultfontsize/24
$pref::graal::dontconnectlevels boolean
$pref::graal::dontloadlistheads boolean
$pref::graal::dontsavepasswords boolean
$pref::graal::dontsavepms boolean
$pref::graal::fixedport boolean
$pref::graal::fixedudpport integer
$pref::graal::language string
$pref::graal::limitnicknames boolean
$pref::graal::loadbuddylistfromserver boolean
$pref::graal::nicknamelimit integer
$pref::graal::nomassmessages boolean
$pref::graal::notoalls boolean
$pref::graal::noudp boolean
$pref::graal::showyourselfonbuddylists boolean
$pref::input::mousesensitivity float
$pref::interior::lockarrays boolean
$pref::terrain::enabledetails boolean
$pref::video::detailfactor float
$pref::video::fogdistance float
$pref::video::fullscreenmode string
$pref::video::screenshotformat string
$pref::video::visibledistance float
$pref::video::windowmode string
$scenelighting::lightingprogress float (read only)

Variables

Name Type Description
allfeatures integer (read only) for use with enablefeatures(), it's the default unless it is changed.
allplayerscount integer (read only) The size of the allplayers array.
allrenderobjecttypes integer (read only)
allstats integer (read only) A bitflag of all stats currently enabled
canspin boolean (read only) True if the player has spin attack
carriesblackstone boolean (read only) True if the player is carrying a black stone
carriesbush boolean (read only) True if the player is carrying a bush
carriesnpc boolean (read only) True if the player is carrying an NPC.
carriessign boolean (read only) True if a player is carrying a sign.
carriesstone boolean (read only) True if a player is carrying a stone.
carriesvase boolean (read only) True if a player is carrying a vase.
downloadfile string (read only) Name of the file currently being downloaded
downloadpos integer (read only) Amount of download file already downloaded
downloadsize integer (read only) Size of the file being downloaded
editingmission boolean
emoticonchar string (read only) The letter of the emoticon being displayed by the player
focusx float (read only) X coordinate of the center of playing screen in the level, offset -1.5
focusy float (read only) Y coordinate of the center of playing screen in the level, offset -2
graalversion float (read only) Graal version
gravity float Downward acceleration for projectiles ejected with the shoot() function.
iscarrying boolean (read only) True if the player is carrying anything
isfocused boolean (read only)
isgraal3d boolean (read only) True if you are running graal 3D
isleader boolean (read only) signifies that the player is the first person in the level
isonmap boolean (read only) signifies that the player is on a map
jpegquality integer
lastdownloadfile string (read only)
leftmousebutton boolean (read only) True if the left mouse button is down
levelorgx float (read only) The x-value of the levels' origin (may deviate with attachplayertoobj)
levelorgy float (read only) The y-value of the levels' origin (may deviate with attachplayertoobj)
lighteffectsenabled boolean (read only) signifies that the player has enabled light effects
weathereffectsenabled boolean (read only) signifies that the player has enabled weather effects
particleeffectsenabled boolean (read only) signifies that the player has enabled particle effects
middlemousebutton boolean (read only) True if the middle mouse button is down
mousebuttons integer (read only) Counts the amount of mousebuttons pressed
mousescreenx integer X coordinate of the mouse on the GUI layer
mousescreeny integer Y coordinate of the mouse on the GUI layer
mousewheeldelta integer (read only) Amount that the mouse scroll wheel was scrolled [(-) is up, (+) is down]
mousex float X coordinate of the mouse on the tile layer
mousey float Y coordinate of the mouse on the tile layer
musiclen integer (read only) The duration of the playing sound file
musicpos integer (read only) The position in the file at which the sound file is
rightmousebutton boolean (read only) True if the right mouse button is down
screenheight integer (read only) Height of the Graal window
screenwidth integer (read only) Width of the Graal window
scriptedcontrols boolean (read only)
scriptedplayerlist boolean (read only)
selectedlistplayers object an array of players highlighted on the playerlist
selectedsword integer
selectedweapon integer Index of player.weapons that references the player's current weapon
servername string (read only) Name of the current server
serverstartconnect string
serverstartparams string
shotbybaddy boolean (read only) True if the player was shot by a baddy
shotbyplayer boolean (read only) True if the player was shot by another player
showterraingrid boolean
timevar integer (read only) A timer which is increased each 5 seconds and is snychronized between server and clients; The timer started exactly on 2001-02-01 at 18:33:34 Paris time (opening of Graal2001); on serverside the unixtime (timevar2) is around 981048814 + timevar*5
timevar2 float (read only) Unix-time with a very high precision, not synchronized between server and client
timevar3 float (read only) synchronized time which works on both server- and client-side, precision is milliseconds, only available for Graal3D right now
wasshooted boolean (read only)
waterheight float The height of water at the player's (x,y) on a terrain
weapons object (read only) An array of weapon objects
weaponsenabled boolean Are weapons enabled? (Player can trigger onWeaponFired...)
worldclockstopped boolean
worldhour integer
worldminute float
worldminutesofday float
worldrealsecondsperday float

Variable Prefixes

Prefix Description
object.var accesses the variables of the object. The object can be retrieved by using the case-sensitive name of the object or a variable pointing to the object.
this.var variables that belong to the current script object, on the server-side they are saved to file when the object is a database npc
thiso.var refer to the this. variables of the executing npc ('o' stands for original) when you use the with () command: with (findnpc("npc2")) thiso.temp = this.temp; will copy 'this.temp' from npc2 to the current npc
temp.var variables that belong to the current function. They can be used anywhere in the function even when referencing another object. Function parameters are declared as temp variables if they do not have a prefix. Temp variables will be destroyed at the end of the function.
player.var variables of the current player object, when the event was invoked by a player (e.g. playertouchsme), or you do with (findplayer(accountname))
playero.var variables of the original player object, in generally the player who has invoked the event (e.g. playertouchsme)
client.var short for player.client.var, variables that can be changed on server-side and client-side
clientr.var short for player.clientr.var, variables that can only be changed on server-side but can be read on client-side
server.var variables that only exists on server-side and can be accessed by all npcs
serverr.var variables that can only be changed on server-side and is server wide, but can also be read by all clients, so it can be used for storing the state of global activities that need client-side actions like displaying weather; like server. vars they can also be changed with remotecontrol.exe by administrators that have the right to change server. variables
level.var variables of the current level, which is the level the executing npc stands in (on server-side) or the player is in (on client-side)

Functions

Note: Currently this doesn't list the functions which are optimized at compile time, see Starting Guide: Standard functions for those.

Common

  • aindexof(float, array) - returns integer, better use array.index(float) instead
  • echo(str text) - prints text in the F2 window (clientside) or RC chat (serverside)
  • getbasepackage() - returns TUpdatePackage object
  • getdownloadedupdatepackagesize() - returns integer
  • getdownloadingpackage() - returns TUpdatePackage object
  • getdownloadingpackagescount() - returns integer
  • gethttprequest(str, int, str) - returns THTTPRequest object
  • getkeycode(str keyname) - returns integer
  • getpackagesdownloadcomplete() - returns boolean
  • getpackagesdownloaded() - returns boolean
  • getplatform() - returns string
  • getservername() - returns string
  • gettotalupdatepackagesize() - returns integer
  • getupdatepackage(str) - returns object
  • isadminguild(str guildname) - returns boolean
  • isobject(str objectname) - returns boolean, checks if an object is existing
  • keydown(int keynumber) - returns if the specified key is pressed (0..10: up, left, down, right, S, A, D, M, tab, Q, P)
  • keydown2(int keycode, bool ignorecase) - returns boolean
  • keyname(int keycode) - returns string
  • opengraalurl(str url) - opens a website of www.graalonline.com and automatically lets the player login to it (e.g. for the upgrade page or screenshot section)
  • openurl(str url)
  • openurl2(str url, int width, int height) - deprecated, width and height are ignored
  • requesthttp(str, int, str) - returns THTTPRequest object
  • requesttext(str type, str option)
  • requesturl(str url) - returns THTTPRequest object
  • savelog(str text)
  • savelog2(str filename, str text) - adds a log entry to "logs/filename"
  • sendrpgmessage(str text) - adds text to the F2 window
  • sendtext(str type, str option, params...)
  • sendtorc(str text) - serverside only, displays text on the RC chat
  • serverwarp(str servername) - the name can either be the internal name (graal2002) or part of the server name on the serverlist

Files

  • extractfilebase(str filepath) - returns string, '/an/example/path/and/file' would return '/an/example/path/and/'
  • extractfileext(str filepath) - returns string, 'filename.ext' would return '.ext'
  • extractfilename(str filepath) - returns string, '/an/example/path/and/file' would return 'file'
  • extractfilepath(str filepath) - returns string, '/an/example/path/and/file' would return '/an/example/path/and/'
  • fileexists(str filepath) - returns boolean, checks if a file exists
  • filesize(str filepath) - returns integer, returns the size of a file
  • fileupdate(str filepath) - returns boolean, checks if a file is existing and requests an update from the server if it has not been checked yet
  • findfiles(str filenamepattern, flags) - returns array of strings, flags can be either 1 for recursive search or 0 for non-recursive
  • freefileresources(str)
  • getextension(str filepath) - returns string, 'filename.ext' would return '.ext'
  • requestfiledeletion(str filepath), requests a file to be deleted on the server
  • requestfilerename(str filepath, str newfilepath), requests a file to be renamed on the server
  • requestfilesmove(str filepath, str newfilepath), requests a file to be moved on the server
  • selectfilefordownload(str filter)
  • selectfileforupload()

Watch the TGraalVar object for loading and saving of files (loadlines etc.)

See more information about input/output at Output methods

Math

  • degtorad(float value) - returns float
  • radtodeg(float value) - returns float
Matrices

GraalScript matricies are arrays of seven elements: three describing translation (position), three describing the rotation axis, and one describing the angle.

  • matrixcreate(str vector, str rotation) - returns matrix string
  • matrixcreatefromeuler(str eulerrotation) - returns matrix string
  • matrixmulpoint(str, str) - returns string
  • matrixmultiply(str matrix, str matrix) - returns matrix string
  • matrixmulvector(str matrix, str vector) - returns vector string
Vectors

Each vector is basicly an array of format {x,y,z} but is passed as string for simplicity. Click on the function names to see more information about the vector operations.

Strings

  • base64decode(str text) - returns decoded string
  • base64encode(str text) - returns encoded string
  • checksum(str text) - returns checksum (integer)
  • contains(str haystack, str needle) - returns boolean, you should probably do haystack.contains(needle) instead
  • getascii(str character) - returns ASCII value integer
  • getstringkeys(str leading) - searches for variables which start with the specified string and returns an array of their endings
  • lowercase(str text) - returns lowercased string, it is recommended to use string.lower() though
  • md5(str text) - returns md5 hash string
  • randomstring(array of strings) - returns string
  • strcmp(str text1, str text2) - returns integer (0 if the strings are equal, a negative value if text1 is alphabetically before text2, otherwise a postive value)
  • strequals(str text1, str text2) - returns boolean, you probably should do text1.equals(text2) or simply text1==text2 instead
  • uppercase(str text) - returns uppercased string, it is recommended to use string.upper() though

GUI

  • addcontrol(obj) - adds a GUI control or a 3D-object to the scene
  • cursoroff()
  • cursoron()
  • iscursoron() - returns boolean
  • popdialog() - removes the top dialog control
  • pushdialog(obj) - displays a control on top of all other controls, this control gains all focus until it is removed again
  • setcontentcontrol(obj) - replaces the current content control (usually named GUIContainer) with another one

Graal 2D

Name Type Description
addtiledef(str tilesetimage, str prefix, int tilesettype) Sets the tileset image for levels beginning with the specified prefix.

Tileset type 0 is for pics1.png style tilesets. Tileset type 1 is for the new tileset format (Era's tiles for example)

addtiledef2(str tilesetimage, str prefix, int x, int y) Replaces a section of the tileset (x, y) image for levels beginning with the specified prefix.
attachplayertoobj(int objtype, int id) Attaches a player to the specified object. Using attachpayertoobj(0, id); the player will be attached to the current NPC.
callnpc(int npcindex, params...) Invokes an event on an npc, better use npcs[npcindex].trigger(event, params) instead; you can only trigger objects this way that are on your side of clientside/serverside
callweapon(int weaponindex, params...) Invokes a trigger on a weapon, better use weapons[weaponindex].trigger(event, params) instead
detachplayer() Puts the player back on the level (after using attachplayertoobj).
disabledefmovement() Disables the default movement.
disablemap() Disables the default map
disablepause() Disables pausing.
disableselectweapons() Disables the default Q menu.
disableweapons() Disables weapons.
enabledefmovement() Enables default movement
enablefeatures(int flags) Enable/disable client features

Flags can consist of:

Value Description
1 M key (map)
2 P key (pause)
4 Q key (weapon select)
8 R key (show ratings)
0x10 S+A key combination for dropping items
0x20 S+D key combination for switching weapons
0x40 TAB key (if disabled then you cannot switch to the chat field with TAB)
0x80 Display of chat text
0x100 Display of the hearts over player heads
0x200 Display of nicknames
0x400 Toall/PM-icons on the minimap
0x800 Right-click on players opens their profile
0x1000 Emoticons (disable it if you want to do other stuff with control+keys)
0x2000 Alt+5 for making snapshots (deprecated)
0x4000 Alt+8/9 for zooming (deprecated)
0x8000 Allows F2 output (savelog()/echo())
allfeatures All of the previously stated feature flags enabled
enablemap() Enables default map.
enablepause() Enables pausing.
enableselectweapons() Enables default Q menu.
enableweapons() Enables weapons.
explodebomb(int bombindex) Explodes a bomb with the specified index.
findani(str) TGraalAni object
findlevel(str levelfilename) TServerLevel object
findplayer(str accountname) TServerPlayer object Returns player object of Account specified. Player must be online.
findplayerbyid(int playerid) TServerPlayer object Returns player object of id specified. If id isn't available, returns false.
findweapon(str weaponname) TServerWeapon object Returns weapon object of the specified name if the player has that weapon.
findweaponnpc(str weaponname) TServerWeapon object Returns weapon object if it exits on the server, only works on server-side. You can normally also access weapons by just typing their name though (e.g. MyWeapon.functionname() instead of findweaponnpc("MyWeapon").functionname())
freezeplayer(float seconds) Freezes player for a specific amount of time.
getimgheight(str imagefilename) integer Returns the height (in pixels) of an image.
getimgwidth(str imagefilename) integer Returns the width (in pixels) of an image.
getmapx(str levelname) integer X coordinate of the level on a map (top-left level is 0)
getmapy(str levelname) integer Y coordinate of the level on a map (top-left level is 0)
gettextheight(float, str, str) integer Returns the height of the font. Format:
 gettextheight(zoom, font, style)
gettextwidth(float, str, str, str) integer Returns the width of a specified text in a certain font. Format:
 gettextwidth(zoom, font, style, text)
getz(float x, float y) float Returns the z value of a terrain at (x,y).
graalcontrolhasfocus(bool) boolean parameter says if it should also check if the chat bar has the focus
hideplayer(float seconds) Hides the player for seconds seconds.
hidesword(float seconds) Hides the player's sword for seconds seconds.
hitnpc(int, float, float, float)
hitobjects(float, float, float)
hitplayer(int, float, float, float)
lay2(str extraname, float x, float y)
loadmap(str mapfilename) Preloads a gmap on clientside, speeds up entering of new maps but is not required.
noplayerkilling() Disables killing of other players. This also lets players walk through other players (players are not blocking anymore).
onwall(float x, float y) boolean Returns true if the specified x and y is a blocking tile.
onwall2(float x, float y, float width, float height) boolean Returns true if a blocking tile exists in the specified area.
onwater(float x, float y) boolean Returns true if the specified x and y is water.
onwater2(float x, float y, float width, float height) boolean Returns true if water exists in the specified area.
play(str soundfilename) Plays the specified sound file.
play2(str soundfilename, float x, float y, float volume) Plays the specified sound file at location x, y with the specified volume. Volume should be between 0 and 1, if volume is set to 1 default volume is used (depending on how far away the player is).
playlooped(str soundfilename) Plays the specified sound file in a loop until stopsound() is called.
playlooped2(str soundfile, float x, float y, float volume) Plays the specified sound file at location x, y with the specified volume in a loop until stopsound() is called. Volume should be between 0 and 1, if volume is set to 1 default volume is used (depending on how far away the player is).
putleaps(int leapstype, float x, float y)
removetiledefs(str prefix) Remove tile definitions set by addtiledef and addtiledef2 for the specified prefix.
replaceani(str defaultaniname, str newaniname) replaces the player's default ani with the new ani.
resetfocus() Sets the screen focus to the player (default focus behaviour).
say(int signindex)
say2(str text)
screenx(float x, float y) integer returns the x of the screen layer for a location on the tiles layer.
screeny(float x, float y) integer returns the y of the screen layer for a location on the tiles layer.
worldx(float x, float y) float returns the x of the tiles layer for a location on the screen layer.
worldy(float x, float y) float returns the y of the tiles layer for a location on the screen layer.
setani(str aniname, str aniparams) Sets the gani of a player.
setbeltcolor(str color)
setcoatcolor(str color)
seteffect(float red, float green, float blue, float alpha) Displays a 'day-night' effect on top of the game. Default value is (0,0,0,0). Change alpha to make the screen darker. You can reach the same effect if you use a polygon (showpoly()) and set the mode to 3. To manipulate the color of a single npc, see setcoloreffect() for TServerNPC.
setfocus(float x, float y) Sets the screen focus to the specified x and y. Use resetfocus() to switch back to the default focus behaviour.
setgender(str gendername) Sets the gender of a player.
sethead(str imagefilename) Sets the head of a player
setletters(str imagefilename) Sets the image to use for sign background and text.
setmap(str textfile, str image, float defaultx, float defaultx) Sets a text map (you can see the tiles of other levels but not the npcs), use gmaps if possible instead of this; the parameter order has been changed between GS1 and GS2 to match the server option "bigmap="
setminimap(str textfile, str image, float defaultx, float defaulty) Sets the mini map, use gmaps if possible instead of this; the parameter order has been changed between GS1 and GS2 to match the server option "minimap="
setmusicvolume(float, float)
setplayerdir(str)
setshield(str imagefilename, int shieldpower)
setshoecolor(str color)
setshootparams(str params)
setskincolor(str color)
setsleevecolor(str color)
setsword(str imagefilename, int swordpower)
showstats(int statsflag) With this you can show/hide parts of the status bar / game

Examples:

// Shows all
showstats(allstats);

// Enable everything except minimap
showstats(allstats & ~0x100);

// Enable everything except AP and MP bars
showstats(allstats & ~(0x40 | 0x80));

// Enable only players and right-click profile
showstats(0x400 | 0x800);

// Hides all
showstats(0);

Flags can consist of:

Value Description
1 ASD
2 Icons (for rupees, bombs, arrows)
4 Rupees count
8 Bombs count
0x10 Arrows count
0x20 Hearts
0x40 Alignment (ap) bar
0x80 Magic points (mp) bar
0x100 Minimap (you can only hide it, you can't show it when the player pressed Alt+3)
0x200 Inventory NPCs
0x400 Players
0x800 Right-click on players opens their profile
allstats All of the previously stated stats flags enabled
spyfire(int length, int power) Shoots a line of fire in the direction of the player with the specified tile length, and fire power (1 - bomb, 2 - super bomb, 3 - jolt bomb).
stopmidi()
stopsound(str soundfilename) Stop playing a sound started by playlooped
takeplayercarry()
takeplayerhorse()
testplayer(float x, float y) integer checks if there is a player on that position and returns the index of the player in players[], or -1 if there is none
triggeraction(float x, float y, str eventname, params...) Invokes an "onActionEventname" event on objects at the specified position, can be used to invoke events on objects from clientside to serverside and vice versa.

Special eventnames are "serverEventname" which will invoke an event on the Control-NPC (onActionEventname), or "serverside" which will invoke an onActionServerSide event on the weapon script specified by the first following parameter (the fourth parameter). It is recommended to use triggerserver() for that though.

Example:

triggeraction(30, 30, "explode", 5);
triggeraction(0, 0, "serverchat", player.chat);
triggeraction(0, 0, "serverside", "PlasmaGun", "activate");
triggerserver(str objecttype, str objectname, str params) Invokes an event on a serverside object, currently objecttype can only be "gui" or "weapon" (which is the same), objectname is the name of the weapon script, the invoked event will be "onActionServerSide".

On Graal3D the event will be "onActionParam0" instead. For invoking events on the clientside use player.triggerclient(objecttype,objectname,params) instead.

Example:

triggerserver("weapon", "PlasmaGun", "activate");
updateboard(int x, int y, int width, int height)
updateratings(obj) object Updates an array of {rating1,ratingdeviation1, rating2,ratingdeviation2, ...}, init them at 1500 and 350.

Example:

newratings = updateratings({winner.rating,winner.ratingd,loser.rating,loser.ratingd});
winner.rating = newratings[0];
winner.ratingd = newratings[1];
loser.rating = newratings[2];
loser.ratingd = newratings[3];
wraptext(int fontsize, str format, str text) array of strings
wraptext2(int pixelwidth, float zoom, str delimiters, str text) array of strings wraps the text so that it fits in the specified number of pixels and returns an array of text lines

Graal 3D

  • getboxcenter(str box) - returns string
  • get3dobjectat(float x, float y, bool doboxcollision) - returns object - gets the 3d object at the specified screen position, third parameter says if it should do box collision
  • get3dobjectatmouse(bool doboxcollision) - returns object - gets the 3d object at the mouse, specify if it should do box collision (true)
  • get3dobjectbyray(str vector, str vector) - returns object
  • lightscene() - returns boolean
  • setfogcolors(array)
  • setinteriorrendermode(int)
  • setskybandcolors(array)
  • setskybandsizes(array)
  • setsuncolors(array)
  • setterrainrendermode(int)
  • synctimeofday(float hour, float minute)
  • updateterrain()
  • updatevisibledistance()

Classes / Object Types