Zen and the Art of Coding (Full Version)

All Forums >> [New Releases from Matrix Games] >> Advanced Tactics Series >> Mods and Scenarios



Message


lancer -> Zen and the Art of Coding (6/24/2011 1:16:56 PM)


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.

Scripting Events

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).

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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_1.jpg[/image]



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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_2.jpg[/image]



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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_3.jpg[/image]



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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_4.jpg[/image]



Here’s the fun part. Press Language.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_5.jpg[/image]



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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_6.jpg[/image]



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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_7.jpg[/image]



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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_8.jpg[/image]



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.



[image]http://i258.photobucket.com/albums/hh262/plugger_photo/z_9.jpg[/image]



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.

Cheers,
Lancer




Barthheart -> RE: Zen and the Art of Coding (6/24/2011 1:35:53 PM)

Great post Lancer! Thanks for taking the time to write it up and post it.
[sm=00000436.gif]




JJKettunen -> RE: Zen and the Art of Coding (6/24/2011 2:24:13 PM)

Very useful! Cheers!




Jeffrey H. -> RE: Zen and the Art of Coding (6/25/2011 2:52:46 AM)

You forgot to open your post with 'G'day' this time.




lancer -> RE: Zen and the Art of Coding (6/25/2011 6:59:53 AM)

G'day,

quote:

You forgot to open your post with 'G'day' this time.


Buddha wouldn't approve.

Cheers,
Lancer




Ande -> RE: Zen and the Art of Coding (6/25/2011 4:44:58 PM)

If it ever was made possible to import written scripts into the game, I would seriously consider making a c/c++ compiler for the atgscript. An abstract sort of object orientation shouldn't be a problem, dynamically allocating memory will probably be impossible though.




Jeffrey H. -> RE: Zen and the Art of Coding (7/5/2011 8:15:56 PM)


quote:

ORIGINAL: lancer

G'day,

quote:

You forgot to open your post with 'G'day' this time.


Buddha wouldn't approve.

Cheers,
Lancer


Yeah well I suppose it was in poor taste. Excellent work on your mods, I wish I had time to explore them, maybe in the coming months.




Jeffrey H. -> RE: Zen and the Art of Coding (7/5/2011 8:17:41 PM)

Oh regarding your link to "the tool" there is a redundant "http//" callout.




bwheatley -> RE: Zen and the Art of Coding (9/20/2012 4:06:46 PM)

I will add this for future searchers. lancer debug atg :)




CSO_Talorgan -> RE: Zen and the Art of Coding (2/20/2013 9:23:30 PM)

This post would be entertaining and informative even if I wasn't interested in ATG. Lancer would be a good author. Maybe he is already.




mgaffn1 -> RE: Zen and the Art of Coding (2/22/2013 5:54:50 PM)

thanks for sharing this!




Jenska -> RE: Zen and the Art of Coding (5/18/2013 10:07:45 PM)

What version of Notepad++ were you using then. ATG doesn't seem tobe in the list anymore.




lancer -> RE: Zen and the Art of Coding (5/18/2013 11:52:33 PM)

G'day Jenska,

ATG isn't in any Notepad++ list, you have to add it. Easy to do. Details in the original post.

Cheers,
Lancer




Jenska -> RE: Zen and the Art of Coding (5/19/2013 12:38:10 AM)

Oh DUH[&:]
I Was so excited to see the good stuff, I missed the add-in part.....




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.875