Ignore:
Timestamp:
12/05/10 08:45:08 (9 years ago)
Author:
technomage
Message:

Patch by aspidites

  • Clarified the PARPG path constants in the dialogue_demo.py script.
  • Significantly simplified the selectDialogueFile method in the dialogue_demo.py script.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/dialogue_demo.py

    r681 r682  
    2727from scripts.quest_engine import QuestEngine 
    2828 
    29 PARPG_ROOT_DIR = os.path.split(sys.argv[0])[0] 
     29PARPG_ROOT_DIR = os.path.dirname(__file__) 
    3030"""Absolute path to the root of the PARPG installation.""" 
    3131DIALOGUE_DIR = os.path.join(PARPG_ROOT_DIR, 'dialogue') 
     
    9595    to select one for testing. 
    9696    """ 
    97     dialogue_files = [] 
    98     for file_name in os.listdir(DIALOGUE_DIR): 
    99         dummy, file_ext = os.path.splitext(file_name) 
    100         file_path = os.path.join(DIALOGUE_DIR, file_name) 
    101         if os.path.isfile(file_path) and file_ext == '.yaml': 
    102             dialogue_files.append(file_name) 
    103             index = len(dialogue_files) - 1 
    104             print('{0} - {1}'.format(index, file_name)) 
     97    dialogue_files = [file_name for file_name in os.listdir(DIALOGUE_DIR)  
     98                      if file_name.endswith('.yaml')] 
     99    for index, file_name in enumerate(dialogue_files): 
     100        print('{0} - {1}'.format(index, file_name)) 
    105101    while True: 
    106102        str_input = raw_input("> ") 
Note: See TracChangeset for help on using the changeset viewer.