diff options
| author | jj | 2012-09-22 11:57:33 +0200 |
|---|---|---|
| committer | jj | 2012-09-22 11:57:33 +0200 |
| commit | ebd4b94c2d26f18bfde389fed910eb69dccd7ced (patch) | |
| tree | 32b619a3bd25c4256d28ba5382be3bc234f26402 | |
| parent | b3ae67cc8bfe48520daf85b0e1fe614531c6bd6c (diff) | |
| download | dfhack-ebd4b94c2d26f18bfde389fed910eb69dccd7ced.tar.gz dfhack-ebd4b94c2d26f18bfde389fed910eb69dccd7ced.tar.bz2 dfhack-ebd4b94c2d26f18bfde389fed910eb69dccd7ced.tar.xz | |
ruby: add onupdate_register_once
| -rw-r--r-- | plugins/ruby/ruby.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/ruby/ruby.rb b/plugins/ruby/ruby.rb index ef6af04e..aeae101d 100644 --- a/plugins/ruby/ruby.rb +++ b/plugins/ruby/ruby.rb @@ -81,6 +81,13 @@ module DFHack end end + # same as onupdate_register, but remove the callback once it returns true + def onupdate_register_once(*a) + handle = onupdate_register(*a) { + onupdate_unregister(handle) if yield + } + end + TICKS_PER_YEAR = 1200*28*12 # this method is called by dfhack every 'onupdate' if onupdate_active is true def onupdate |
