summaryrefslogtreecommitdiff
path: root/plugins/ruby/ruby.rb
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-09-27 10:36:14 +0400
committerAlexander Gavrilov2012-09-27 10:36:14 +0400
commit2e5f3c46201d8450a39b52117dbd4f1544771189 (patch)
tree1215abb52b93463c894b459462bb30cf36be8c81 /plugins/ruby/ruby.rb
parentac9e78a6130d896510f186cc8f8ed5046cac45be (diff)
parent7cc29250f8622a317da464a2b7356a246082abc0 (diff)
downloaddfhack-2e5f3c46201d8450a39b52117dbd4f1544771189.tar.gz
dfhack-2e5f3c46201d8450a39b52117dbd4f1544771189.tar.bz2
dfhack-2e5f3c46201d8450a39b52117dbd4f1544771189.tar.xz
Merge remote-tracking branch 'jjyg/master'
Diffstat (limited to 'plugins/ruby/ruby.rb')
-rw-r--r--plugins/ruby/ruby.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/ruby/ruby.rb b/plugins/ruby/ruby.rb
index aeae101d..81b73b7c 100644
--- a/plugins/ruby/ruby.rb
+++ b/plugins/ruby/ruby.rb
@@ -119,6 +119,14 @@ module DFHack
@onstatechange_list.delete b
end
+ # same as onstatechange_register, but auto-unregisters if the block returns true
+ def onstatechange_register_once
+ handle = onstatechange_register { |st|
+ onstatechange_unregister(handle) if yield(st)
+ }
+ end
+
+
# this method is called by dfhack every 'onstatechange'
def onstatechange(newstate)
@onstatechange_list ||= []