README.md in gamefic-sdk-3.0.0 vs README.md in gamefic-sdk-3.0.1

- old
+ new

@@ -35,54 +35,67 @@ You can enter commands at the `>` prompt, but you haven't written any content, so there's not much to do yet. Enter `QUIT` to exit the game. ### The Script Code -The main script for your narrative is `main.rb` in your project's root -directory. It should look something like this: +The plot for your narrative is defined in the `plot.rb` file. It should look +something like this: ```ruby -GAMEFIC_UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' -require 'gamefic-standard' +module Example + class Plot < Gamefic::Plot + UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' -Gamefic.script do - introduction do |actor| - actor.tell "Hello, world!" + include Gamefic::Standard + + script do + introduction do |actor| + actor.tell "Hello, world!" + end + end end end ``` -`GAMEFIC_UUID` is a globally unique identifier. It can be useful if you want to +`UUID` is a globally unique identifier. It can be useful if you want to add your game to online catalogs, such as the [Interactive Fiction Database](https://ifdb.tads.org/), but it's safe to delete if you don't need it. ['gamefic-standard'](https://github.com/castwide/gamefic-standard) is a collection of baseline features that are frequently useful for interactive fiction. [Inform](http://inform7.com/) developers should find it similar to Inform's Standard Rules. It defines common components like Rooms and Characters, along with in-game commands like `GO`, `GET`, and `DROP` to enable basic interactivity. -`Gamefic.script` is where you write the story itself. In the starter project, +`script` is where you write the story itself. In the starter project, the only thing in the script is an introductory message. ### Modifying the Script -Replace the contents of `main.rb` with the following: +Replace the contents of `plot.rb` with the following: ```ruby -require 'gamefic-standard' +module Example + class Plot < Gamefic::Plot + UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' -Gamefic.script do - @living_room = make Room, name: 'living room', description: 'This is your living room.' - @bedroom = make Room, name: 'bedroom', description: 'This is your bedroom.' - connect @living_room, @bedroom, 'north' - @backpack = make Room, name: 'backpack', description: 'Your trusty backpack.', parent: @bedroom - @book = make Room, name: 'book', description: 'Your favorite novel.', parent: @living_room + include Gamefic::Standard - introduction do |actor| - actor.parent = @living_room - actor.tell "You're in your house." + seed do + @living_room = make Room, name: 'living room', description: 'This is your living room.' + @bedroom = make Room, name: 'bedroom', description: 'This is your bedroom.' + connect @living_room, @bedroom, 'north' + @backpack = make Room, name: 'backpack', description: 'Your trusty backpack.', parent: @bedroom + @book = make Room, name: 'book', description: 'Your favorite novel.', parent: @living_room + end + + script do + introduction do |actor| + actor.parent = @living_room + actor.tell "You're in your house." + end + end end end ``` Enter `rake ruby:run` to test the game. Now that it has rooms and objects, you @@ -102,30 +115,29 @@ ``` $ rake web:run ``` -Open `http://localhost:4342` to run the game in debug mode. +Open `http://localhost:9000` to run the game in debug mode. Build a standalone web game: ``` $ rake web:build ``` The game's HTML file and related assets will be generated in the -`builds/web/production` directory. The SDK uses -[opal](https://github.com/opal/opal) to compile Ruby code to JavaScript, so the -web build does not require a Ruby interpreter. Open `index.html` in a browser -to play the game. +`web/build` directory. The SDK uses opal](https://github.com/opal/opal) +to compile Ruby code to JavaScript, so the web build does not require a +Ruby interpreter. Open `index.html` in a browser to play the game. Note: building the web app requires [Node.js](https://nodejs.org). ### Example Projects The gamefic-sdk repo includes several example projects that provide more complete demonstrations of Gamefic's features. To run an example, copy -its `main.rb` file to your own project. +its `plot.rb` file to your own project. ### Learning More Go to the [Gamefic website](https://gamefic.com) for more information about developing and building apps with Gamefic.