An open API service indexing awesome lists of open source software.

https://github.com/jamis/ifrb

Interactive Fiction for Interactive Ruby
https://github.com/jamis/ifrb

Last synced: 7 months ago
JSON representation

Interactive Fiction for Interactive Ruby

Awesome Lists containing this project

README

          

# ifrb

Interactive fiction (IF), for interactive Ruby (IRB). Play interactive fiction games from within the cozy familiarity of irb! Write stories that incorporate actual, executable Ruby code in the dialog!

## Installation

RubyGems is your friend:

$ gem install ifrb

## Usage

Try it with one of the examples:

$ ifrb basil

Or, if you want to do it from within IRB directly:

$ irb
irb> require 'ifrb'
irb> ifrb "basil"

## Writing Your Own Adventures

Just create a new ruby file. You need at least one method, called `start`, which will be called when your adventure loads.

def start
# ...
end

Define methods inside that method to add actions that are available for players. At the very least, you should add a method called `look`, which will be called when the room loads. The `look` method should describe the room:

def start
def look
_format <<-DESC
You see a big room. Not much else in here.
DESC
end

# ...
end

Other rooms are defined as top-level methods:

def start
#...
end

def monster
def look
_format "Yuck! A monster!"
end
# ...
end

Transition to rooms using the `_load_room` method:

def start
def north
_load_room :monster
end
end

def monster
# ...
end

See the examples for more information about writing your own adventures. Good luck!

## License

Creative Commons Attribution 4.0 International License -- (c) Jamis Buck

Creative Commons License
IFRB by Jamis Buck is licensed under a Creative Commons Attribution 4.0 International License.
Based on a work at http://github.com/jamis/ifrb.