diff --git a/NEWS b/NEWS index 2a7508f5f..e52e76998 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ DFHack future - Is not yet known. + Misc improvements: + - digfort: improved csv parsing, add start() comment handling + DFHack v0.34.11-r4 New commands: diff --git a/Readme.rst b/Readme.rst index a2b400206..fe7fb741e 100644 --- a/Readme.rst +++ b/Readme.rst @@ -2171,7 +2171,12 @@ Unrecognized characters are ignored (eg the 'skip this tile' in the sample). Empty lines and data after a ``#`` are ignored as comments. To skip a row in your design, use a single ``;``. -The script takes the plan filename, starting from the root df folder. +One comment in the file may contain the phrase ``start(3,5)``. It is interpreted +as an offset for the pattern: instead of starting at the cursor, it will start +3 tiles left and 5 tiles up from the cursor. + +The script takes the plan filename, starting from the root df folder (where +Dwarf Fortress.exe is found). invasion-now ============ diff --git a/scripts/digfort.rb b/scripts/digfort.rb index cf3625357..74db423d3 100644 --- a/scripts/digfort.rb +++ b/scripts/digfort.rb @@ -4,15 +4,47 @@ raise "usage: digfort " if not $script_args[0] planfile = File.read($script_args[0]) if df.cursor.x == -30000 - raise "place the game cursor to the top-left corner of the design" + puts "place the game cursor to the top-left corner of the design" + throw :script_finished end -tiles = planfile.lines.map { |l| - l.sub(/#.*/, '').split(/[;,]/).map { |t| t = t.strip ; ((t[0] == ?") ? t[1..-2] : t) } +# a sample CSV file +# empty lines are ignored +# a special comment with start(dx, dy) means the actual patterns starts at cursor.x-dx, cursor.y-dy +# the CSV file should be saved in the main DF directory, alongside of Dwarf Fortress.exe +sample_csv = <