Merge remote-tracking branch 'PeridexisErrant/digfort-checks'

Conflicts:
	NEWS
develop
lethosor 2015-01-05 16:32:14 -05:00
commit 3bc17dafab
2 changed files with 48 additions and 52 deletions

@ -3,6 +3,7 @@ DFHack Future
plugins will not be loaded if globals they specify as required are not located (should prevent some crashes) plugins will not be loaded if globals they specify as required are not located (should prevent some crashes)
Fixes Fixes
advfort works again advfort works again
digfort: now checks file type and existence
exportlegends: Fixed map export exportlegends: Fixed map export
full-heal: Fixed a problem with selecting units in the GUI full-heal: Fixed a problem with selecting units in the GUI
gui/hack-wish: Fixed restrictive material filters gui/hack-wish: Fixed restrictive material filters

@ -1,31 +1,26 @@
# designate an area for digging according to a plan in csv format # designate an area for digging according to a plan in csv format
raise "usage: digfort <plan filename>" if not $script_args[0] fname = $script_args[0].to_s
planfile = File.read($script_args[0])
if df.cursor.x == -30000 if not $script_args[0] then
puts "place the game cursor to the top-left corner of the design" puts " Usage: digfort <plan filename>"
throw :script_finished
end
if not fname[-4..-1] == ".csv" then
puts " The plan file must be in .csv format."
throw :script_finished
end
if not File.file?(fname) then
puts " The specified file does not exist."
throw :script_finished throw :script_finished
end end
# a sample CSV file planfile = File.read(fname)
# empty lines are ignored
# a special comment with start(dx, dy) means the actual patterns starts at cursor.x-dx, cursor.y-dy if df.cursor.x == -30000
# the CSV file should be saved in the main DF directory, alongside of Dwarf Fortress.exe puts "place the game cursor to the top-left corner of the design and retry"
sample_csv = <<EOS throw :script_finished
# start(3, 4) end
,d,d,d,d,d,d
d, , , , , , ,d
d, , , , , , ,d
d, ,d, , ,d, ,d
h, , , , , , ,h
h,h,h,h,h,h,h,h
h,h, ,d,d, ,h,h
h,h,h,h,h,h,h,h
,h,h,h,h,h,h
, , ,h,h,h
, , , ,h,h
EOS
offset = [0, 0] offset = [0, 0]
tiles = [] tiles = []
@ -43,7 +38,7 @@ planfile.each_line { |l|
} }
} }
x = x0 = df.cursor.x - offset[0] x = df.cursor.x - offset[0]
y = df.cursor.y - offset[1] y = df.cursor.y - offset[1]
z = df.cursor.z z = df.cursor.z
@ -63,7 +58,7 @@ tiles.each { |line|
end end
x += 1 x += 1
} }
x = x0 x = df.cursor.x - offset[0]
y += 1 y += 1
} }