You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# designate an area based on a '.csv' plan=begindigfort=======A script to designate an area for digging according to a plan in csv format.This script, inspired from quickfort, can designate an area for digging.Your plan should be stored in a .csv file like this:: # this is a comment d;d;u;d;d;skip this tile;d d;d;d;iAvailable tile shapes are named after the 'dig' menu shortcuts:``d`` for dig, ``u`` for upstairs, ``j`` downstairs, ``i`` updown,``h`` channel, ``r`` upward ramp, ``x`` remove designation.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 ``;``.One comment in the file may contain the phrase ``start(3,5)``. It is interpretedas an offset for the pattern: instead of starting at the cursor, it will start3 tiles left and 5 tiles up from the cursor.additionally a comment can have a < for a rise in z level and a > for drop in z.The script takes the plan filename, starting from the root df folder (where``Dwarf Fortress.exe`` is found).=endfname= $script_args[0].to_smap=df.world.mapXsentinel=map.x_count - 1Ysentinel=map.y_count - 1Xstamp=falseYstamp=falseif not $script_args[0]thenputs" Usage: digfort <plan filename>"throw:script_finishedendif not fname[-4..-1] == ".csv"thenputs" The plan file must be in .csv format."throw:script_finishedendif not File.file?(fname)thenputs" The specified file does not exist."throw:script_finishedendplanfile=File.read(fname)ifdf.cursor.x == -30000puts"place the game cursor to the top-left corner of the design and retry"throw:script_finishedendoffset=[0,0]tiles=[]max_x=0max_y=0y=0planfile.each_line{ |l|
ifl =~ /#.*start\s*\(\s*(-?\d+)\s*[,;]\s*(-?\d+)/raise"Error: multiple start() comments"ifoffset != [0,0]offset=[$1.to_i, $2.to_i]endifl.chomp == '#<'l='<'y=0endifl.chomp == '#>'l='>'y=0endl=l.chomp.sub(/#.*/,'')nextifl == ''x=0tiles << l.split(/[;,]/).map{ |t|
t=t.stripifx < Xsentinelthenx += 1elsex=Xsentinel;Xstamp=trueendmax_x=xifx > max_xand not t.empty?(t[0] == '"') ? t[1..-2] : t}ify < Ysentineltheny += 1elsey=Ysentinel;Xstamp=trueend}x=df.cursor.x - offset[0]y=df.cursor.y - offset[1]z=df.cursor.zstarty=y - 1ifx < 0ory < 0orx+max_x >= map.x_countory+max_y >= map.y_countmax_x=max_x + x + 1max_y=max_y + y + 1raise"Position would designate outside map limits. Selected limits are from (#{x+1}, #{y+1}) to (#{max_x},#{max_y})"endtiles.each{ |line|
nextifline.empty?orline == ['']line.each{ |tile|
iftile.empty?ifx < Xsentinelthenx += 1elsex=Xsentinel;Xstamp=trueendnextendt=df.map_tile_at(x,y,z)s=t.shape_basiccasetilewhen'd';t.dig(:Default)ifs == :Wallwhen'u';t.dig(:UpStair)ifs == :Wallwhen'j';t.dig(:DownStair)ifs == :Wallors == :Floorwhen'i';t.dig(:UpDownStair)ifs == :Wallwhen'h';t.dig(:Channel)ifs == :Wallors == :Floorwhen'r';t.dig(:Ramp)ifs == :Wallwhen'x';t.dig(:No)when'<';y=starty;z += 1when'>';y=starty;z -= 1endifx < Xsentinelthenx += 1elsex=Xsentinel;Xstamp=trueend}x=df.cursor.x - offset[0]ify < Ysentineltheny += 1elsey=Ysentinel;Ystamp=trueend}ifXstamporYstampthenputs'Warning: ' + (Xstamp ? 'the columns': '') + (XstampandYstamp ? ' and ': '') + (Ystamp ? 'the rows' : '') + ' of the blueprint that overflow the designable area of the Dwarf Fortress embark have been ignored'puts' if your blueprint X or Y dimension is close to that of the embark map, this warning is probably a false positive due to faulty logic in this script'endputs' done'
The text was updated successfully, but these errors were encountered:
From Abadrausar: http://www.bay12forums.com/smf/index.php?topic=164123.msg8091067#msg8091067
The text was updated successfully, but these errors were encountered: