Module: Gamefic::Scriptable

Includes:
Hooks, Queries, Responses, Scenes, Seeds, Syntaxes
Included in:
Narrative, Scripting
Defined in:
lib/gamefic/scriptable.rb,
lib/gamefic/scriptable/hooks.rb,
lib/gamefic/scriptable/seeds.rb,
lib/gamefic/scriptable/scenes.rb,
lib/gamefic/scriptable/queries.rb,
lib/gamefic/scriptable/syntaxes.rb,
lib/gamefic/scriptable/responses.rb

Overview

A class module that enables scripting.

Narratives extend Scriptable to enable definition of scripts and seeds. Modules can also be extended with Scriptable to make them includable to other Scriptables.

Examples:

Include a scriptable module in a plot

module MyScript
  extend Gamefic::Scriptable

  respond :myscript do |actor|
    actor.tell "This command was added by MyScript"
  end
end

class MyPlot < Gamefic::Plot
  include MyScript
end

Defined Under Namespace

Modules: Hooks, Queries, Responses, Scenes, Seeds, Syntaxes

Instance Attribute Summary

Attributes included from Scenes

#default_conclusion, #default_scene

Instance Method Summary collapse

Methods included from Syntaxes

#interpret, #syntaxes

Methods included from Seeds

#construct, #make, #seed, #seeds

Methods included from Scenes

#active_choice, #block, #conclusion, #introduction, #introductions, #multiple_choice, #named_scenes, #pause, #scene_classes, #scene_classes_map, #scenes, #select_default_conclusion, #select_default_scene, #yes_or_no

Methods included from Responses

#meta, #respond, #responses, #responses_for, #verbs

Methods included from Queries

#available, #children, #descendants, #extended, #global, #integer, #myself, #parent, #plaintext, #siblings

Methods included from Hooks

#after_command, #after_commands, #before_command, #before_commands, #conclude_blocks, #on_conclude, #on_player_conclude, #on_player_output, #on_player_ready, #on_player_update, #on_ready, #on_update, #player_conclude_blocks, #player_output_blocks, #ready_blocks, #update_blocks

Instance Method Details

#included_scriptsObject



40
41
42
# File 'lib/gamefic/scriptable.rb', line 40

def included_scripts
  ancestors.that_are(Scriptable).uniq
end

#pick(*args) ⇒ Proxy::Pick Also known as: lazy_pick

Lazy pick an entity.

Examples:

pick('the red box')

Parameters:

Returns:



66
67
68
# File 'lib/gamefic/scriptable/seeds.rb', line 66

def pick *args
  Proxy::Pick.new(*args)
end

#pick!(*args) ⇒ Object Also known as: lazy_pick!

Note:

The class method version of ‘pick!` returns a proxy, so the error won’t get raised until it gets unproxied in an instance.

Lazy pick an entity or raise an error.



76
77
78
# File 'lib/gamefic/scriptable/seeds.rb', line 76

def pick! *args
  Proxy::PickEx.new(*args)
end