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
- Host: GitHub
- URL: https://github.com/jamis/ifrb
- Owner: jamis
- Created: 2015-10-17T20:00:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-17T20:01:14.000Z (over 10 years ago)
- Last Synced: 2025-04-16T03:17:12.552Z (about 1 year ago)
- Language: Ruby
- Size: 125 KB
- Stars: 23
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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

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.