diff options
| author | jj | 2012-09-01 02:55:55 +0200 |
|---|---|---|
| committer | jj | 2012-09-01 03:22:48 +0200 |
| commit | dcc9498dbc9e7bf5c477af28659aac2aac58b525 (patch) | |
| tree | acd8bca605615d0e1b369dc90548770e37ad4119 /plugins/ruby | |
| parent | ce608e4f6aabef63d8e0da265e964b00109e5380 (diff) | |
| download | dfhack-dcc9498dbc9e7bf5c477af28659aac2aac58b525.tar.gz dfhack-dcc9498dbc9e7bf5c477af28659aac2aac58b525.tar.bz2 dfhack-dcc9498dbc9e7bf5c477af28659aac2aac58b525.tar.xz | |
ruby: tweak apis
Diffstat (limited to 'plugins/ruby')
| -rw-r--r-- | plugins/ruby/building.rb | 8 | ||||
| -rw-r--r-- | plugins/ruby/plant.rb | 12 |
2 files changed, 11 insertions, 9 deletions
diff --git a/plugins/ruby/building.rb b/plugins/ruby/building.rb index af152e19..cb435b9d 100644 --- a/plugins/ruby/building.rb +++ b/plugins/ruby/building.rb @@ -46,6 +46,7 @@ module DFHack raise "invalid building type #{type.inspect}" if not cls bld = cls.cpp_new bld.race = ui.race_id + subtype = WorkshopType.int(subtype) if subtype.kind_of?(::Symbol) and type == :Workshop bld.setSubtype(subtype) if subtype != -1 bld.setCustomType(custom) if custom != -1 case type @@ -176,9 +177,10 @@ module DFHack # set building at position, with optional width/height def building_position(bld, pos, w=nil, h=nil) - bld.x1 = pos.x - bld.y1 = pos.y - bld.z = pos.z + x, y, z = (pos.respond_to?(:x) ? [pos.x, pos.y, pos.z] : pos) + bld.x1 = x + bld.y1 = y + bld.z = z bld.x2 = bld.x1+w-1 if w bld.y2 = bld.y1+h-1 if h building_setsize(bld) diff --git a/plugins/ruby/plant.rb b/plugins/ruby/plant.rb index 5d6b9d72..2f5a1c7c 100644 --- a/plugins/ruby/plant.rb +++ b/plugins/ruby/plant.rb @@ -51,7 +51,7 @@ module DFHack end SaplingToTreeAge = 120960 - def cuttrees(material=nil, count_max=100) + def cuttrees(material=nil, count_max=100, quiet=false) if !material # list trees cnt = Hash.new(0) @@ -62,7 +62,7 @@ module DFHack } cnt.sort_by { |mat, c| c }.each { |mat, c| name = @raws_tree_name[mat] - puts " #{name} #{c}" + puts " #{name} #{c}" unless quiet } else cnt = 0 @@ -78,11 +78,11 @@ module DFHack break if cnt == count_max end } - puts "Updated #{cnt} plant designations" + puts "Updated #{cnt} plant designations" unless quiet end end - def growtrees(material=nil, count_max=100) + def growtrees(material=nil, count_max=100, quiet=false) if !material # list plants cnt = Hash.new(0) @@ -93,7 +93,7 @@ module DFHack } cnt.sort_by { |mat, c| c }.each { |mat, c| name = @raws_tree_name[mat] - puts " #{name} #{c}" + puts " #{name} #{c}" unless quiet } else cnt = 0 @@ -104,7 +104,7 @@ module DFHack cnt += 1 break if cnt == count_max } - puts "Grown #{cnt} saplings" + puts "Grown #{cnt} saplings" unless quiet end end end |
