Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Comments in DF Macros?  (Read 1304 times)

Pirate Bob

  • Bay Watcher
  • [ETHIC: TORTURE_FOR_SCIENCE: ACCEPTABLE]
    • View Profile
Comments in DF Macros?
« on: September 12, 2012, 11:08:21 am »

I've been writing some pretty long macros for ammo testing, and I was wondering if anyone knows if its possible to put comments in DF macros?  Things I have tried seem to cause errors, and the syntax requirements of macros aren't really described on the wiki.  Thanks in advance for any suggestions!

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: Comments in DF Macros?
« Reply #1 on: September 12, 2012, 01:32:55 pm »

I believe that the answer to this is no, it's currently impossible to put comments into DF macros. What you could do is set up a "macro comments.txt" file that you then open side-by-side with the macro and that has comments on the corresponding lines though.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Pirate Bob

  • Bay Watcher
  • [ETHIC: TORTURE_FOR_SCIENCE: ACCEPTABLE]
    • View Profile
Re: Comments in DF Macros?
« Reply #2 on: September 12, 2012, 02:40:06 pm »

Thanks for the response and suggestion i2amroy.  What I really want is to be able to have big, easy to find comments, so that when I am cutting and pasting things I can easily see "this is the block for adding chainmail armor", "this block adds a row of dwarves" etc. 

I will have to play around with putting in fake commands.  I know that some things (including blank lines) will just crash DF outright, but I might be able to find something that just complains to errlog.txt without crashing DF

Di

  • Bay Watcher
    • View Profile
Re: Comments in DF Macros?
« Reply #3 on: September 13, 2012, 01:06:51 pm »

How do you even write macros? For me it failed to load a macro that simply had a few copypasted lines added to macros created ingame.
Logged
Quote from: Creamcorn
Dwarf Fortress: Where you meet the limit of your imagination, moral compass, sanity and CPU processor.
http://www.bay12forums.com/smf/index.php?topic=103080.0 Fix sober vampires!
http://www.bay12forums.com/smf/index.php?topic=91442.0 Dwarven Cognitive Science

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: Comments in DF Macros?
« Reply #4 on: September 13, 2012, 02:06:19 pm »

Did you make sure to revert the file to .mak? You will need to rename the file after you save it since most text editors won't save in that format by default. Then also make sure that it actually converts the file, some OS's will just rename the file to be xxxx.mak(.txt), leaving it as a text file.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Pirate Bob

  • Bay Watcher
  • [ETHIC: TORTURE_FOR_SCIENCE: ACCEPTABLE]
    • View Profile
Re: Comments in DF Macros?
« Reply #5 on: September 13, 2012, 05:36:59 pm »

Also be sure to restart Dwarf Fortress every time you make any changes to a macro.  At least on Linux macros appear to be loaded when Dwarf Fortress launches.

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: Comments in DF Macros?
« Reply #6 on: September 13, 2012, 06:35:27 pm »

Also be sure to restart Dwarf Fortress every time you make any changes to a macro.  At least on Linux macros appear to be loaded when Dwarf Fortress launches.
Same on mac and windows.
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Pirate Bob

  • Bay Watcher
  • [ETHIC: TORTURE_FOR_SCIENCE: ACCEPTABLE]
    • View Profile
Re: Comments in DF Macros?
« Reply #7 on: September 13, 2012, 09:08:40 pm »

Also be sure to restart Dwarf Fortress every time you make any changes to a macro.  At least on Linux macros appear to be loaded when Dwarf Fortress launches.
Same on mac and windows.
To be more specific, I think the macros are actually read the first time you press "Ctrl+L", at least that's when the errors show up ;).  The point is they only get loaded once.

Another potential macro pitfall that I just remembered - if you make a copy of an existing macro, you need to make sure to change the name in the first line.  Otherwise DF will only recognize one of the two macros with the same name (probably the one with the first file name alphabetically, but I'm not sure). 

And, finally, the answer to my own question.  If you don't mind DF spamming errors to the terminal/errlog, adding random text which is not on the same line as any other commands seems to work fine.  In particular, I added text of the form ****THIS IS A COMMENT**** in a few different places, and my macro worked just fine and just gave errors of the form:
Code: [Select]
Quantity not numeric or Unexpected tab(s) while loading macro: End of group
Binding name unknown while loading macro: ****THIS IS A COMMENT****
This is good enough for me, so I will try that.  I want to write a macro that places ~2000 dorfs in rows of 75, and it will be much easier if I can mark ****BEGIN NEW ROW**** etc. 

The error about tabs makes me wonder if macros care about tabs/spaces, which is something I had suspected but not confirmed.  I always just copy and paste from recorded macros, and then delete the unnecessary commands, so I think I usually preserve the spacing.  By messing around, I confirmed that the first character of each line is not read as a command.  If I place "ARENA_CREATURE_SIDE_UP" at the beginning of a line with no space in front of it, I get "Binding name unknown while loading macro:RENA_CREATURE_SIDE_UP".  However, if I put "XARENA_CREATURE_SIDE_UP", where "X" can be a character or space, it works fine.  This make me wonder if the first character of a macro line serves as a flag, as in FORTRAN where placing a "C" at the beginning of a line indicates a comment (this does not get rid of the errors from my comment lines, by the way).  Maybe Toady was planning to use line flags, but didn't implement them yet?  I tried pretty much every typeable character, and none of them seems to do anything.

Thanks very much to i2amroy for your help!