ruby: rename building_isitemfree to item_isfree, add trader flag check

develop
jj 2012-10-01 11:14:00 +02:00
parent d9cd427121
commit fbc2d85609
2 changed files with 13 additions and 11 deletions

@ -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

@ -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