-
Notifications
You must be signed in to change notification settings - Fork 35
Tutorial
To initialize a new story, move to the Tale directory and type:
python -m tale.author init ./stories/[your_story_name]
This will create a default story setup (using the base Garfield story) within the /stories/ subdirectory.
To run this story type (from the Tale directory):
python -m tale.main --game ./stories/[your_story_name]
Test the game out once to ensure it is working properly.
Next, move to the story directory (in Tale/stories/[your_story_name]) and edit the story.py file. Most values should have been set up during the story initialization, but review them and update as needed. Note that you may not be able to fill in the startlocation_player value at this time (you may need to create the starting room first), but you do need to place at least one value (which will be the name of your first file in the zones sub directory) in the "zones" setting. This can be anything at this time, as it will be easy to change later; you just need something to get started. An example might look like:
config.zones = ["forest"]
If you add any additional files in the zones directory, add them to this list so they can be imported into the story.
Once you have updated the story.py file, enter the zones subdirectory and create a new python file whose name matches your zone setting created above (e.g. zone.py). This zone file could contain locations, npcs and items, but it may make sense to organize these into separate files.
Within this zone file, include the following import statement:
from tale.base import Location, Exit, Door
To create a room, first instantiate a Location object.
room_name = Location(name=”RoomName”, descr=”RoomDescription”)
Next, create any exits from the room as follows:
exit1_name = directions(directions=[“direction1”, “direction2”], target_location=”zone.target_room_name”, short_descr=”What the exit looks like”, long_descr=”Detailed description of the exit”)
Note that directions must be one word, and if you define compass directions, you must use the full name (e.g. “north”). However, once you’ve provided the compass direction, the player will be able to use the abbreviation automatically (e.g. “n”). The short description will appear as text along with the room description. The long_descr will show up if someone looks directly at the exit, and it will include a note that the player can go there.
Once you have instantiated all exits, add them to the room as follows:
room.add_exits([exit1_name, exit2_name, exit3_name, etc])
Note that any room referenced in an Exit must be created for the program to run.
Either create a new file for your NPC or add them to a current file in the zones directory. Add the following import if it does not exist, along with text to instantiate an NPC:
from tale.base import Living
class My_npc(Living):
def init(self):
super().init()
Back in your zones file, choose a room. For that room add the following import:
from zones.npc_file_name import my_npc
And below, at an appropriate spot:
my_npc = My_npc(name="npc_name", gender="f", descr="npc description upon examination")
room.insert(my_npc, None)
Run the program and you should find the NPC there, though they perform no actions and do not respond to any commands.