lib/demiurge/dsl.rb
# Perform the given action every so many ticks. This will set up
# the necessary state entries to cause the action to occur each
# time that many ticks pass.  The given action name is attached to
# the given block (if any.) The named action can be modified using
# define_action if you want to set extra settings like engine_code
# or busy for the action in question. If no block is given, you
# should use define_action to create the action in question, or it
# will have no definition and cause errors.
#
# @param action_name [String] The action name for this item to use repeatedly
# @param t [Integer] The number of ticks that pass between actions
# @yield [...] Called when the action is performed with any arguments supplied by the caller
# @yieldreturn [void]
# @return [void]
# @since 0.0.1
Perform the given action every so many ticks. This will set up
the necessary state entries to cause the action to occur each
time that many ticks pass.  The given action name is attached to
the given block (if any.) The named action can be modified using
define_action if you want to set extra settings like engine_code
or busy for the action in question. If no block is given, you
should use define_action to create the action in question, or it
will have no definition and cause errors.
Perform the given action every so many ticks . This will set up the necessary state entries to cause the action to occur each time that many ticks pass . The given action name is attached to the given block ( if any . ) The named action can be modified using define_action if you want to set extra settings like engine_code or busy for the action in question . If no block is given you should use define_action to create the action in question or it will have no definition and cause errors .
def every_X_ticks(action_name, t, &block)
      raise("Must provide a positive number for how many ticks, not #{t.inspect}!") unless t.is_a?(Numeric) && t >= 0.0
      @built_item.state["everies"] ||= []
      @built_item.state["everies"] << { "action" => action_name, "every" => t, "counter" => 0 }
      @built_item.register_actions(action_name => { "name" => action_name, "block" => block })
      nil
    end
def every_X_ticks ( action_name , t , & block ) raise ( "Must provide a positive number for how many ticks, not #{t.inspect}!" ) unless t . is_a? ( Numeric ) && t >= 0.0 @built_item . state [ "everies" ] ||= [ ] @built_item . state [ "everies" ] << { "action" => action_name , "every" => t , "counter" => 0 } @built_item . register_actions ( action_name => { "name" => action_name , "block" => block } ) nil end
Perform the given action every so many ticks.
Perform the given action every so many ticks .
None
void
None
void
action_name
The action name for this item to use repeatedly
The action name for this item to use repeatedly
t
The number of ticks that pass between actions
The number of ticks that pass between actions
block
]
Called when the action is performed with any arguments supplied by the caller
Called when the action is performed with any arguments supplied by the caller
since
None