Zen and the Art of Coding
“Be at one with the code, grasshopper. Let your thoughts flow like the river through your keyboard. Float gently down the path to ATG enlightenment.”
Nice if you can manage it. All I can do is stumble blindly through the potholes.
After an initial learning curve I’ve figured out how to stumble in the right direction. More or less. Here are a few things that have helped that might be off interest to others.
Once you get your head around the particular way the editor works you can do a fair bit. It’s surprisingly powerful. This is good.
What’s not so good is that when you start becoming more adventurous and begin churning out longer scripts (more than what fits on a single screen) to do ever more complicated things, you – or more precisely, me – bang hard up against the editor’s limitations.
All that black and green retro text starts to blur and you soon loose your way. This is the point where you feel the need for a tool.
Enter stage right – the TOOL.
(I’m not sure if I’m allowed to mention other programs here so henceforth, after a brief introduction, it will be referred to as the TOOL).
Notepad++ is an open-source code editor. It’s one of those do everything, hugely complicated, fancy text editors. Actually it does do everything, is pretty easy to figure out and is free.
Here’s how it works with ATG.
On the Event scripting page of the Editor is a blue button, top right. There are other, lesser, blue buttons but they are best not mentioned in polite company. Any trouble, call the police.
Press the blue button. It exports a copy of all your events into the /logs directory (ATG game folder). Like thus.
Double click on all the events that you are working on or wish to view. Naturally, when you installed the TOOL you associated all “.txt” with it so double clicking automatically opens the TOOL with each of your events in it’s own neat and tidy, separate tab.
Looks like this.
Apart from the monochromatic colour change this isn’t much better. Note in the screenshot above I’ve renamed the files within the TOOL to give them the same name as in the editor. This – as you’ll see shortly – isn’t a good idea.
Here’s the fun part. Press Language.
You are given a drop down list of every programming language that ever there was. Even the whacky ones. Not terribly useful but right at the bottom – helpfully highlighted above – is ATG.
H*ly Bat Cr*p! Does THE TOOL have inbuilt support for Advanced Tactics Gold?
Yep. Pretty slick. I press ‘ATG’ and the script fairy waves her magic wand and this is what I suddenly have. Cinderella ready for the ball.
Wow. Now this is useful. For a start it’s highly readable. You can easily match CHECKS with their missing cousin END CHECK’s. What’s even better is that all the power of the TOOL is at your fingertips.
Click on a variable. Viola, all the other instances where that variable is used are highlighted.
If you have opened up all your scripts then you can get a list of where a particular variable – say a game or regime variable - occurs, right across your entire script library. And so on. Terribly helpful.
If you have to rename a variable to something else then the automatic highlighting of each instance enables you to dive into the ATG editor and quickly and accurately ripple through the change ‘cause the line number references are the same as in the TOOL.
I’ve got a dual monitor setup so I have the TOOL open on one monitor and the ATG editor on the other. ALT-TAB’ing would work with a single monitor, not with the same ease of use but still handy.
When running the scripts (eg. playing the game) I can quickly debug any problems that occur as I have access to both the scripts (in the TOOL) and what’s happening onscreen, in-game, simultaneously.
Now unfortunately it’s all one way travel, script wise, from ATG to the TOOL. A journey with no return. Hasta la vista, baby.
However you can make the journey multiple times. All you have to do is press the blue button (mentioned above) from within the editor and any changes you have made to the scripts are updated – real time – in the TOOL. Extremely useful.
(If you rename your files from event58.txt to “Node Initialisation”, for example as I did above, it won’t update. Stick with the default)
The TOOL enables you to develop and debug an awful lot faster than if you were working exclusively within ATG.
Oh, the bit above where I mentioned that support for the ATG scripting language is built into the TOOL - I lied.
There is a button. Known only to a select few. Plus you. Don’t tell your neighbours.
This allows you to create support for a custom language – like ATG. Very involved. Took me all of three minutes and I’m a person who can’t even remember to put the garbage out.
This is how it works. You can see that I’ve told it to colour every instance of CHECK and END CHECK blue. Tempvar’s purple, Loops with a yellow background etc. Choose your own scheme. Change font sizes. Change fonts. Buy a dog. Easy.
That’s the TOOL. Recommended.
I was intending to mention a number of scripting tips that I’ve found useful but won’t. Given that I’ve only been playing around with the editor for a month or so, anyone who has bothered to read this far probably knows a lot more about it than me.
When I get stuck I’ll ask you.
< Message edited by lancer -- 7/5/2011 10:51:02 PM >