From fbc2d85609808b69f27f5653d8898eabfbfce242 Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 1 Oct 2012 11:14:00 +0200 Subject: [PATCH] ruby: rename building_isitemfree to item_isfree, add trader flag check --- plugins/ruby/building.rb | 12 +----------- plugins/ruby/item.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/ruby/building.rb b/plugins/ruby/building.rb index 59f715515..08c12a841 100644 --- a/plugins/ruby/building.rb +++ b/plugins/ruby/building.rb @@ -352,23 +352,13 @@ 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 - building_isitemfree(i) + item_isfree(i) } raise 'no free bed, build more !' if not item diff --git a/plugins/ruby/item.rb b/plugins/ruby/item.rb index fc840f7ad..9a254d9e8 100644 --- a/plugins/ruby/item.rb +++ b/plugins/ruby/item.rb @@ -47,5 +47,17 @@ module DFHack raise "what what?" end end + + # check item flags to see if it is suitable for use as a job input material + def item_isfree(i) + !i.flags.trader and + !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 + end end