diff --git a/.gitignore b/.gitignore index 739b0d7..e451507 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ venv/ .idea config.ini fortunes.txt +offline_game_tester.py diff --git a/command_handlers.py b/command_handlers.py index 9f9b8ce..ce2259b 100644 --- a/command_handlers.py +++ b/command_handlers.py @@ -806,7 +806,6 @@ def start_selected_game(sender_id, interface, state): # Present the first segment present_story_segment(sender_id, interface, new_state) # ✅ Pass updated state - def load_game_map(file_path): """Loads a game map from a CSV file and returns its structured format.""" @@ -828,7 +827,7 @@ def load_game_map(file_path): game_title = first_line.split("=", 1)[1].strip().strip('"') game_lines = lines[1:] # Skip title else: - game_title = file_path # Use filename if no title + game_title = os.path.splitext(os.path.basename(file_path))[0] # Use filename without path/extension game_lines = lines print(f"DEBUG: Game title detected -> {game_title}") diff --git a/gamefile_syntax.md b/gamefile_syntax.md index 822824a..6c2d5cf 100644 --- a/gamefile_syntax.md +++ b/gamefile_syntax.md @@ -31,6 +31,8 @@ title="The Mysterious Forest" - If present, the game uses this as the **title**. - If absent, the **filename** is used as the title. - The second line will then be the **first story segment**. +- If present, the game will consider the title line as line 0. +- Line 1 is always the first story segment. --- @@ -63,4 +65,7 @@ title="The Mysterious Forest" ## 📌 **Final Notes** By following this format, you can create **interactive, branching text adventures** without modifying code! 🎮🚀 +Remember, if using a title in the first line you need to offset your line mapping by -1. It's easiest to write +the story and mapping first, then adding the title after you're done. If you forget to offset your line numbers, +a simple script to increment each choice number by -1 will fix it for you! diff --git a/games/lost_forest_no_title b/games/lost_forest_no_title new file mode 100644 index 0000000..8aa02c0 --- /dev/null +++ b/games/lost_forest_no_title @@ -0,0 +1,7 @@ +What is your first choice?, East, 2, West, 3, North, 4, South, 5 +You chose East. A dense forest appears., Run forward, 6, Look around, 7 +You chose West. A river blocks your path., Try to swim, 8, Walk along the bank, 9 +You chose North. The path is blocked by rocks. +You chose South. A cave entrance looms ahead., Enter the cave, 10, Turn back, 11 +You went East and chose to run. The ground gives way and you fall. GAME OVER. +You went East and looked around. You see a hidden path., Follow it, 12, Stay put, 13 \ No newline at end of file