Page 1 of 1

Scripting Tips

Posted: Fri Sep 14, 2012 2:03 am
by zaroba
Anybody else that wants to is free to post their tips as well.


*Planning - Before starting any script and while making it, I've always made and kept a list of all the playervars, servervars, and buildingvars being used and what they are being used for. This is probably the single most useful thing to do as it eliminates accidentally using the same var for different things, or accidentally using two different vars for the same thing. Plus it saves you from having to search all over a script to see if a var is being used already.

*Organization - Once a script is completed, organization isn't much to worry about. But while you are working on a script it makes making it so much easier. Having different parts of the script in different text files makes working on them far easier then trying to do everything in the servers script file. You can easily open different parts of the script for reference, easily see formulas you typed, and copy bits of script to retype them. Keeping the main server script free of programming also provides you with a place to test pieces of script to make sure they will work.

*Testing - test, test, test, test. Just in case I'm not clear enough, test, test, and test some more. Even if it looks good, test it. Even if you've tested all the small parts of a large event, test the larger event as well. Once the script is completed, try and test as much as you can. Try and trigger all the automatic events, activate the manual events, try and click all the different buttons. It *really* sucks to spend a lot of time on a script and find out it doesn't work, all because there is a missing or extra bracket or a simple typo somewhere. For best results, do the testing when the world *isn't* running, like while you are making a world. This way any vars set can easily be erased and there's no chance of something messing up in the script and effecting players.

*Bug Fixing - So after all of the above, you find something doesn't work in the script. Easiest way to find what is causing the trouble is to go to the event that isn't working and start reading. Read threw the script and try to follow the path that the game will follow when going threw the event. It can take a while depending on the size of it, but if your reading threw it and basically pretending to be a computer following instructions you will find what isn't working.