ruby: add onupdate_register_once

develop
jj 2012-09-22 11:57:33 +02:00
parent b3ae67cc8b
commit ebd4b94c2d
1 changed files with 7 additions and 0 deletions

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