- v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
- Use this page to report any issues related to the migration.
Difference between revisions of "v0.34:Cleaning up macros"
(this should probably just be deleted) |
m (Reverted edits by 74.105.188.206 (talk) to last revision by Sasf54) |
||
Line 1: | Line 1: | ||
− | + | == Cleaning up Macros == | |
+ | |||
+ | This page is dedicated, on to describe, and help in cleaning macros. This is needed, because a recorded macro contains quite a lot of other interface interaction, what can really slow the executing. | ||
+ | |||
+ | Because DF has a cache for the macros, you must change at least the name of the macro inside it (use a counter, and increment it), otherwise, the oldest loaded version will be used :( | ||
+ | |||
+ | If you make your macros to do a repetative job in a single menu, you can easily use grep and a menu macro file. Grep[http://gnuwin32.sourceforge.net/packages/grep.htm] is a GNU utility, that process an input (text) file, and throws everything, that doesn't match the filtering options. It's a very powerful utility, so if you would like to know better, look into manual[http://unixhelp.ed.ac.uk/CGI/man-cgi?grep]. Because grep is case sensitive (CAPITAL non capital), you have to watch out for this, or use a -i (in-case sensitive) mode. | ||
+ | |||
+ | === How to use them === | ||
+ | Because grep is not saving the first line (name of macro), you have to make it manually. | ||
+ | You have two choices. You can create a file, with the appropriate menu name, for example build.menu, and then: | ||
+ | echo my1 > my1.mak | ||
+ | grep -f build.menu my.mak >> my1.mak | ||
+ | Don't forget, to clean up any empty lines from the '''.menu''' file, otherwise, nothing will then filtered out. | ||
+ | Second method, use a bunch of patterns | ||
+ | echo my2 > my2.mak | ||
+ | grep -e line_1_from_file -e line_2_from_file -e line_3_from_file my.mak >> my2.mak | ||
+ | |||
+ | For both cases the first line is writing my2 (the name of the macro) into the file. This operation will overwrite the existing content of the file. The second line is actually doing the filtering, and appending the file. (Don't run, otherwise you wish to double the macro, you will still have to delete the '''End of macro''' line from the middle of the file)). | ||
+ | === Some useful filter === | ||
+ | ====Build menu==== | ||
+ | If you wish to build anything, and you are not intended to leave the build menu, and the macro is not selecting the building type, you can use the following file / listing to filter your macro. (so, for 'you manually select the first position, and the building type, and then run the macro' type of macros). | ||
+ | SELECT | ||
+ | End of group | ||
+ | CURSOR_ | ||
+ | End of macro | ||
+ | |||
+ | ====Resizing menu==== | ||
+ | If you wish to resize some building, you should use this filter, to speed things up. It will leave all the resizing commands, so it will be still valid for other building resizing. (If you recorded for bedrooms, you still can use for stone gardens...) | ||
+ | SELECT | ||
+ | SECONDSCROLL_ | ||
+ | CURSOR_ | ||
+ | _SIZE | ||
+ | End of group | ||
+ | End of macro |
Revision as of 19:58, 16 September 2013
Cleaning up Macros
This page is dedicated, on to describe, and help in cleaning macros. This is needed, because a recorded macro contains quite a lot of other interface interaction, what can really slow the executing.
Because DF has a cache for the macros, you must change at least the name of the macro inside it (use a counter, and increment it), otherwise, the oldest loaded version will be used :(
If you make your macros to do a repetative job in a single menu, you can easily use grep and a menu macro file. Grep[1] is a GNU utility, that process an input (text) file, and throws everything, that doesn't match the filtering options. It's a very powerful utility, so if you would like to know better, look into manual[2]. Because grep is case sensitive (CAPITAL non capital), you have to watch out for this, or use a -i (in-case sensitive) mode.
How to use them
Because grep is not saving the first line (name of macro), you have to make it manually. You have two choices. You can create a file, with the appropriate menu name, for example build.menu, and then:
echo my1 > my1.mak grep -f build.menu my.mak >> my1.mak
Don't forget, to clean up any empty lines from the .menu file, otherwise, nothing will then filtered out. Second method, use a bunch of patterns
echo my2 > my2.mak grep -e line_1_from_file -e line_2_from_file -e line_3_from_file my.mak >> my2.mak
For both cases the first line is writing my2 (the name of the macro) into the file. This operation will overwrite the existing content of the file. The second line is actually doing the filtering, and appending the file. (Don't run, otherwise you wish to double the macro, you will still have to delete the End of macro line from the middle of the file)).
Some useful filter
If you wish to build anything, and you are not intended to leave the build menu, and the macro is not selecting the building type, you can use the following file / listing to filter your macro. (so, for 'you manually select the first position, and the building type, and then run the macro' type of macros).
SELECT End of group CURSOR_ End of macro
If you wish to resize some building, you should use this filter, to speed things up. It will leave all the resizing commands, so it will be still valid for other building resizing. (If you recorded for bedrooms, you still can use for stone gardens...)
SELECT SECONDSCROLL_ CURSOR_ _SIZE End of group End of macro