diff options
| author | jj | 2012-08-11 20:08:33 +0200 |
|---|---|---|
| committer | jj | 2012-08-11 20:08:33 +0200 |
| commit | 942b245461606a902b6cfda38fcdbf9e3b6c3131 (patch) | |
| tree | a118037472d296174118dfe82e6b8de66ef15e27 /plugins/ruby | |
| parent | 8f4c39d3f5ef22ce4065741e1d0cccde20497493 (diff) | |
| download | dfhack-942b245461606a902b6cfda38fcdbf9e3b6c3131.tar.gz dfhack-942b245461606a902b6cfda38fcdbf9e3b6c3131.tar.bz2 dfhack-942b245461606a902b6cfda38fcdbf9e3b6c3131.tar.xz | |
ruby: add method to check if an item is free for use as construction material
Diffstat (limited to 'plugins/ruby')
| -rw-r--r-- | plugins/ruby/building.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/ruby/building.rb b/plugins/ruby/building.rb index 9a59411f..ab029ac2 100644 --- a/plugins/ruby/building.rb +++ b/plugins/ruby/building.rb @@ -286,14 +286,23 @@ module DFHack job end + # check item flags to see if it is suitable for use as a building material + def building_isitemfree(i) + !i.flags.in_job and + !i.flags.in_inventory and + !i.flags.removed and + !i.flags.in_building and + !i.flags.owned and + !i.flags.forbid + end + # exemple usage def buildbed(pos=cursor) raise 'where to ?' if pos.x < 0 item = world.items.all.find { |i| i.kind_of?(ItemBedst) and - i.itemrefs.empty? and - !i.flags.in_job + building_isitemfree(i) } raise 'no free bed, build more !' if not item |
