From NEAT Portal Wiki
Jump to: navigation, search
(Page created)
(No difference)

Revision as of 17:23, 24 June 2011

Introduction

In this section we will look at some advanced techniques for saving memory, creating reusable blocks and methods of keeping things under control.

Rule #1: Test your script!
This is particularily important for attack scripts and any script that destroys a troop, building or wall defense.
Ideally you would test any such script in an empty city. It is ok to produce errors when you expect them.
Set quantities to minimum numbers until you are sure the script functions properly.
Before you run your market script to sell 9,999,999 food at a time, run it through selling 100 just to test the logic.
Rule #2: Keep your scripts as compact and simple as possible.
This includes using gosub routines and replaceable variables.
Rule #3: Be sure you have enough troops, resources, heroes, and most importantly, time.
There is nothing worse than getting to wave #8 and encountering an "Illegal camp time ignored" error.
Before running an attack script against your enemy, run it against an npc 1 mile beyond your enemy.
This will be further discussed in the attack section.

Y.A.E.B. contains space for 5 scripts per city. You should take advantage of these spaces to store scripts that you use regularly.


Kiss your script

Kiss stands for 'Keep it simple, stupid'. The best way to do this is with sub-routines. Any time your script does the same thing more than once, you should use a sub-routine. Bear in mind, however, that there is absolutely no advantage to having a sub-routine who's only function is to send you somewhere else.

Use repeat and loop whenever you want to run the same command or chunk of commands more than once. Replaceable variables are by far the most economical way to keep your script compact and make it reuseable.

The Simple Attack script is a good example. Simply changing the set xy xxx,yyy and set army xxxx lines will allow you to send any army to any city. The Schwack Attack, found immediately following the previous example is a far more complex example . I keep a copy in one of the script spaces of every city.

The Schwack Attack also demonstrates a simple way of selecting an option from multiple choices. Only the first goto command encountered is able to run, so you simply cut the and paste the attack you want to perform into the first position and run the script. It is best to set the 'always run script from line #1' option in the misc. page of the options. The script was written before this option was availible, and I have since eliminated the 'goto top' line from the end of the script.


A working example

Scripts take up memory. If you have 3 accounts with 9 cities each, with all of them running a 150 line script, you will find yourself hard-pressed for memory real quick.