spacer graphic
spacer graphic
Montage of games AGS Logo
spacer graphic

 

spacer graphic
Menu
spacer graphic Home
About
News
Features
Download AGS
spacer graphic Games 
Games main page
Award Winners
Picks of the month
Short games
Medium length games
Full length games
In Production
Hints & Tips
Community
Forums
AGSers World Map
Member websites
Chat
Resources
Tutorials
FAQ
Knowledge Base
Downloads
Links
AGS-related links
* AGS Manual
  * Scripting

Extender functions

Suppose that you wanted to add a new function, "Scream", to characters which would make them cry out "AARRRGGGHHH". Because the Character type is defined within AGS, it's not possible for you to just add a method to it.

That's where Extender Functions come in. Here's an example:

function Scream(this Character*)
{
this.Say("AAAAARRRRGGGGHHHHHH!!!!");
}
This adds a new "Scream" function to the Character type, so that in your script code elsewhere you can do things like:
player.Scream();
character[EGO].Scream();
and so on.

Where do I put this code?

In the script header, you'd put:

import function Scream(this Character*);

and then put the main function in the script file. This will then allow it to be used by other scripts.


User comments and notes
There are currently no user comments on this page.
The user comment facility is currently disabled.