summaryrefslogtreecommitdiff
path: root/plugins/ruby
diff options
context:
space:
mode:
authorjj2012-07-12 00:44:07 +0200
committerjj2012-07-12 00:44:07 +0200
commit0615a27663adb72990abc9e3084b09df552a35bc (patch)
tree76ffb214c13fa90d5cd2e7ec408a2a46af7c070d /plugins/ruby
parentd8e55196c265e457ca47c5117be8abd493e907ac (diff)
downloaddfhack-0615a27663adb72990abc9e3084b09df552a35bc.tar.gz
dfhack-0615a27663adb72990abc9e3084b09df552a35bc.tar.bz2
dfhack-0615a27663adb72990abc9e3084b09df552a35bc.tar.xz
ruby: refix unit_idlers, make unit_find handle 'u'nitlist viewscreen
Diffstat (limited to 'plugins/ruby')
-rw-r--r--plugins/ruby/unit.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/ruby/unit.rb b/plugins/ruby/unit.rb
index 5b279d0d..ebcf249d 100644
--- a/plugins/ruby/unit.rb
+++ b/plugins/ruby/unit.rb
@@ -6,9 +6,15 @@ module DFHack
# with an argument that respond to x/y/z (eg cursor), find first unit at this position
def unit_find(what=:selected, y=nil, z=nil)
if what == :selected
- if curview._rtti_classname == :viewscreen_itemst
+ case curview._rtti_classname
+ when :viewscreen_itemst
ref = curview.entry_ref[curview.cursor_pos]
ref.unit_tg if ref.kind_of?(GeneralRefUnit)
+ when :viewscreen_unitlistst
+ v = curview
+ # TODO fix xml to use enums everywhere
+ page = DFHack::ViewscreenUnitlistst_TPage.int(v.page)
+ v.units[page][v.cursor_pos[page]]
else
case ui.main.mode
when :ViewUnits
@@ -67,7 +73,7 @@ module DFHack
# filter soldiers (TODO check schedule)
u.military.squad_index == -1 and
# filter 'on break'
- !u.status.misc_traits.find { |t| id == :OnBreak }
+ not u.status.misc_traits.find { |t| t.id == :OnBreak }
}
end