Zen and the Art of Coding

Discuss and post your mods and scenarios here for others to download.

Moderator: Vic

Post Reply
lancer
Posts: 2963
Joined: Tue Oct 18, 2005 8:56 am

Zen and the Art of Coding

Post by lancer »


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



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



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



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



Here’s the fun part. Press Language.



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



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



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



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



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
User avatar
Barthheart
Posts: 3080
Joined: Tue Jul 20, 2004 3:16 pm
Location: Nepean, Ontario

RE: Zen and the Art of Coding

Post by Barthheart »

Great post Lancer! Thanks for taking the time to write it up and post it.
Life is not a journey to the grave with the intention of arriving safely in a pretty & well preserved body,
but rather to skid in broadside, totally worn out & proclaiming "WOW, what a ride!"
User avatar
JJKettunen
Posts: 2289
Joined: Tue Mar 12, 2002 6:00 pm
Location: Finland

RE: Zen and the Art of Coding

Post by JJKettunen »

Very useful! Cheers!
Jyri Kettunen

The eternal privilege of those who never act themselves: to interrogate, be dissatisfied, find fault.

- A. Solzhenitsyn
User avatar
Jeffrey H.
Posts: 3154
Joined: Fri Apr 13, 2007 6:39 pm
Location: San Diego, Ca.

RE: Zen and the Art of Coding

Post by Jeffrey H. »

You forgot to open your post with 'G'day' this time.
History began July 4th, 1776. Anything before that was a mistake.

Ron Swanson
lancer
Posts: 2963
Joined: Tue Oct 18, 2005 8:56 am

RE: Zen and the Art of Coding

Post by lancer »

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

Buddha wouldn't approve.

Cheers,
Lancer
Ande
Posts: 197
Joined: Thu Jul 05, 2007 12:12 pm
Location: Göteborg/Sweden

RE: Zen and the Art of Coding

Post by Ande »

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.
User avatar
Jeffrey H.
Posts: 3154
Joined: Fri Apr 13, 2007 6:39 pm
Location: San Diego, Ca.

RE: Zen and the Art of Coding

Post by Jeffrey H. »

ORIGINAL: lancer

G'day,
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.
History began July 4th, 1776. Anything before that was a mistake.

Ron Swanson
User avatar
Jeffrey H.
Posts: 3154
Joined: Fri Apr 13, 2007 6:39 pm
Location: San Diego, Ca.

RE: Zen and the Art of Coding

Post by Jeffrey H. »

Oh regarding your link to "the tool" there is a redundant "http//" callout.
History began July 4th, 1776. Anything before that was a mistake.

Ron Swanson
bwheatley
Posts: 3654
Joined: Mon Dec 13, 2004 4:08 pm
Contact:

RE: Zen and the Art of Coding

Post by bwheatley »

I will add this for future searchers. lancer debug atg :)
-Alpha Tester Carrier Force
-Beta Tester ATG
- Mod Maintainer (past) for ATG's WAW mod
- Mod Maintainer (past) for ATG's GPW mod
-Beta Tester WITE
-Alpha Tester WITW
-Alpha Tester WITE2
-Alpha Tester Wif
-Beta Tester Command
User avatar
CSO_Talorgan
Posts: 808
Joined: Sat Mar 10, 2007 5:53 pm

RE: Zen and the Art of Coding

Post by CSO_Talorgan »

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
Posts: 175
Joined: Fri Nov 20, 2009 3:54 pm

RE: Zen and the Art of Coding

Post by mgaffn1 »

thanks for sharing this!
Mike
User avatar
Jenska
Posts: 28
Joined: Sat May 11, 2013 3:19 pm
Location: Boston, Mass

RE: Zen and the Art of Coding

Post by Jenska »

What version of Notepad++ were you using then. ATG doesn't seem tobe in the list anymore.
lancer
Posts: 2963
Joined: Tue Oct 18, 2005 8:56 am

RE: Zen and the Art of Coding

Post by lancer »

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
User avatar
Jenska
Posts: 28
Joined: Sat May 11, 2013 3:19 pm
Location: Boston, Mass

RE: Zen and the Art of Coding

Post by Jenska »

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

Return to “Mods and Scenarios”