lib/demiurge/dsl.rb
# If you want to define an action for later calling, or to set
# options on an action that was defined as part of another
# handler, you can call define_action to make that happen.
#
# @example Make an every_X_ticks action also keep the agent busy and run as Engine code
# ```
# every_X_ticks("burp", 15) { engine.item_by_name("sooper sekrit").ruby_only_burp_action }
# define_action("burp", "engine_code" => true, "busy" => 7)
# ```
#
# @param action_name [String] The action name to declare or modify
# @param options [Hash] Options for this action
# @option options [Integer] busy How many ticks an agent should remain busy for after taking this action
# @option options [Boolean] engine_code If true, use the EngineBlockRunner instead of a normal runner for this code; usually a bad idea
# @option options [Array<String>] tags Tags that the action can be queried by later - useful for tagging player or agent actions, or admin-only actions
# @yield [...] Actions receive whatever arguments their later caller supplies
# @yieldreturn [void]
# @return [void]
# @since 0.0.1
If you want to define an action for later calling, or to set
options on an action that was defined as part of another
handler, you can call define_action to make that happen.
If you want to define an action for later calling or to set options on an action that was defined as part of another handler you can call define_action to make that happen .
def define_action(action_name, options = {}, &block)
      legal_options = [ "busy", "engine_code", "tags" ]
      illegal_keys = options.keys - legal_options
      raise("Illegal keys #{illegal_keys.inspect} passed to define_action of #{action_name.inspect}!") unless illegal_keys.empty?;
      register_built_action({ "name" => action_name, "block" => block }.merge(options))
      nil
    end
def define_action ( action_name , options = { } , & block ) legal_options = [ "busy" , "engine_code" , "tags" ] illegal_keys = options . keys - legal_options raise ( "Illegal keys #{illegal_keys.inspect} passed to define_action of #{action_name.inspect}!" ) unless illegal_keys . empty? ; register_built_action ( { "name" => action_name , "block" => block } . merge ( options ) ) nil end
If you want to define an action for later calling, or to set
options on an action that was defined as part of another
handler, you can call define_action to make that happen.
If you want to define an action for later calling or to set options on an action that was defined as part of another handler you can call define_action to make that happen .
None
void
None
void
action_name
The action name to declare or modify
The action name to declare or modify
options
tags Tags that the action can be queried by later - useful for tagging player or agent actions, or admin-only actions
tags Tags that the action can be queried by later - useful for tagging player or agent actions or admin - only actions
block
]
Actions receive whatever arguments their later caller supplies
Actions receive whatever arguments their later caller supplies
example
Make an every_X_ticks action also keep the agent busy and run as Engine code ``` every_X_ticks("burp", 15) { engine.item_by_name("sooper sekrit").ruby_only_burp_action } define_action("burp", "engine_code" => true, "busy" => 7) ```
Make an every_X_ticks action also keep the agent busy and run as Engine code ` ` ` every_X_ticks ( " burp " 15 ) { engine . item_by_name ( " sooper sekrit " ) . ruby_only_burp_action } define_action ( " burp " " engine_code " = > true " busy " = > 7 ) ` ` `
since
None