-- WiP -- I expect every vigilant scripter to pit in here -- WiP --
- Provide an Author and Date of creation/last edited, and optionally a means to get in touch. Email, website, forum.
Looking through your favorite scripts from way back, you find a plugin, and you don't know what it does, who made it, or why the readme didn't provide an author. The scripts are gibberish, and what name you could make out was "sprintf". Who in the abyss is sprintf? Oh wait.. no. Perhaps that was a command? - External/Internal changelog.
Knowing what was fixed might give you a star with the user of your script. Also, when returning to your scripting after a long absence, it's good to have as much info as possible so you know what you were doing in the first place. - Naming Conventions
To improve the readability for your own benefit as well as others, it is a good thing to use descriptive names.Code: Select all
$a1 = $a2 -> get name * versus this $ship.name = $ship.reference -> get name
- Reuse variables
Reusing variables rather than creating new ones should save memory. The more scripts you cram into your game, the more memory it uses. Hence it's a good practice to have variables you can use repeatedly as each new variable eats a bit of memoryCode: Select all
$loop = 10 while $loop dec $loop = ... end ... $loop = 0 while $loop < 15 ... inc $loop = end
- Comment
To further improve readability, use comments, if only to separate sections of your script. A simple dashed line can make a huge difference in the script's appearance - Unique Global Variables
Global variables are just that - global. Which means any script can access them as long as the name is known. That's why it's a good idea to use the script's name and author in the variable to ensure it is unique. Otherwise you might accidentally trample on another script.[/size]Code: Select all
* Good: set global variable: name="yourstruly.myScript.weaponarray" value= $weapon.array * Bad: set global variable: name="array" value= $weapon.array