What's a script do? How do I open them?
A script will let you change items and npcs, make new ones, setup a trigger to react to something, and tons more limited only by your ability to script it and your imagination. When
SphereSvr is started or resynched it loads all your scripts so you can use them. Scripts should be located in your scripts directory or a subdirectory within it. To open a script you can use any text editor. Notepad will work. MS Word is not recommended as it leaves odd formatting. Every good scripter will probably tell you a different program to use, my personal favorite is Editplus (
http://www.editplus.com) with Swindler's
Sphere.stx loaded (available at
ftp://ftp.editplus.com/files/sphere.zip). There are tons of good text editors available on the web. Try a search for one. I recommend something with a find in files option, find/replace option (even better if it can do regular expressions and multiple line replaces), and syntax highlighting (different colors for different words, makes scripts easy to read). If you do not have the
.scp extension on your scripts, please read the
Preparing to use Sphere section of this help file again, and turn on file extensions.
Where do I learn how to script?
Well, you are going to be your own best teacher. Don't be afraid of your scripts in your Sphere script folder. Look at them, copy them to custom script files and edit them. Start off small, change a name or a color or something. Try adding a little extra damage to a weapon. Try adding a sparkle effect to a sword when it hits. When you're comfortable with the basics, then try to script something bigger. I've far too often seen someone come on IRC and say "Hi I'm new, can you tell me how to script a nice race/class/level system?" This is a BAD way to start. You will only get frustrated and give up completely on scripting. If you have previous programming or scripting experience, you might find Sphere scripting easy to learn in a couple hours. Not everyone is already an expert though.. for those we have many resource sites available. The
Links section of this help file will direct you to Scripting for Dummies, a highly praised scripting tutorial site, as well as Sphere Reference Project, a very detailed and established reference site with almost every command available to you in scripts and in game. The SphereServer.com forums are another excellent place. Just reading posts by other people will answer questions for you before you even realize you have them. This help file will cover a very small, very basic couple examples of scripting to get you started. It is not by any means intended to be complete or detailed.
What do I edit?
Try not to edit the default scripts that come with Sphere. Any script named sphere_d_whatever.scp is a default script and shouldn't be edited. Sphere versions 0.53 and higher allow you to place an unlimited number of custom files for Sphere to use, so use them instead of adding to the default scripts. When new releases are made, script updates may be released with them. Placing your custom scripts in the directory with the new Sphere is -much- easier than trying to edit your changes into the new default files or edit the default changes into your old ones. When the scripting language gets an overhaul, you will thank yourself for doing all your changes and new additions in custom files.
Sphere reads the scripts in the order they are loaded, and replaces any duplicates with the last one read. So if you wanted to change, for example: c_ogre, place a new CHARDEF for the ogre in a custom script and load it after the sphere_d_char.scp script (where the ogre is located by default). That will replace the default with yours.
How does Sphere know what to load and when?
Sphere will load anything in the main scripts directory automatically, but unless you want to cause headaches for yourself having things loaded out of order, you should always tell Sphere what to load and in what order to load it. You can do this by adding the script file names to spheretables.scp in the [RESOURCES] section at the top. You can also organize your scripts further by placing them in custom directories within the scripts folder. For example: C:\Sphere\Scripts\NPCS\ and C:\Sphere\Scripts\Items\ and C:\Sphere\Scripts\Custom\. To tell Sphere to load scripts in new custom directories, simply place a path to the directory in the first or second [RESOURCES] section in spheretables.scp. You will notice the Speech and Custom subdirectories are already there.
As stated above, Sphere loads files in the order it is told to, or in the order they're listed in the directory when not told to. If Sphere loads a script that calls to another script definition it hasn't loaded yet, it will error. For example: if you had sphere_d_region.scp telling Sphere to place the regionresource "mr_stuff" in an area before the regionresource "mr_stuff" script itself is loaded, Sphere will give you an error. Make sure anything required for a script to load and run is loaded before the dependant script is loaded.
What do I name my scripts?
Scripts can have any name you wish. The "Sphere" part is not required. What -is- required however is the .scp extension. If you do not have file extensions turned on, please read the Preparing to Use Sphere section of this help file. Try to name your scripts something you can remember and something that describes what will be inside of it. You don't have to have one or two huge scripts with everything in them. Make your life easier by dividing things up into easily read and edited scripts.