Scriptable Modules
Gamefic narratives are designed to be composable with modules. Scenes, responses, and hooks can all be implemented in a scriptable module and included in a narrative. Modules are made scriptable by extending them with Gamefic::Scriptable
.
# lib/mygame/mymodule.rb
module Mygame
module Mymodule
extend Gamefic::Scriptable
respond :foobar do |actor|
actor.tell 'Command provided by Mymodule'
end
end
end
# lib/mygame/plot.rb
module Mygame
class Plot < Gamefic::Plot
include Mymodule # The FOOBAR command gets added to the plot
end
end