import renpy
import os
import sys
import modinfo
import importlib
import modinfo

print('AWSW Mod Loader Init')

def get_mod_path():
    """Get the mod path

    Returns:
        The full path to the mods folder
    """
    #TODO: Use a path combining function
    return renpy.config.gamedir + "/mods/"

# By setting the import path to the mod folder, we can do something like `import mod`
# NOTE: To import files in the modloader/ folder, do `from modloader import ...`
# If we add the modloader to the path, the modlist would get reloaded again
sys.path.append(get_mod_path())

for mod in os.listdir(get_mod_path()):
    # Some mods require resources to be recognized by renpy. If a folder exists, force renpy to load it
    resource_dir = get_mod_path() + mod + "/resource"
    if os.path.isdir(resource_dir):
        renpy.config.searchpath.append(resource_dir)

    # Try importing the mod. If all goes well, the mod is imported through the Mod class
    print("Begin mod load: {}".format(mod))

    mod_object = importlib.import_module(mod)
    
    # Run through the module's attributes to determine whether we should load it as a legacy mod. 
    if not 'loadable_mod' in dir(mod_object):
        modinfo.add_mod(mod, mod_object)

# After all mods are loaded, call their respective mod_complete functions
for mod_name, mod in modinfo.get_mods().iteritems():
    print("Completing mod {}".format(mod_name))
    mod.mod_complete()

# force renpy to reindex all game files
renpy.loader.old_config_archives = None

@@ -73,16 +73,32 @@
  modinfo
+%0Aimport modclass
 %0A%0Aprint(
@@ -1084,162 +1084,223 @@
 ugh 
-the module's attributes to determine whether we should load it as a legacy mod. %0A    if not 'loadable_mod' in dir(mod_object):%0A        modinfo.add_mod(mod
+registry to see if the mod implements loadable_mod in some way. %0A    if not any(modinfo.get_mods()%5Bkey%5D%5B4%5D == mod_object for key in modinfo.get_mods()):%0A        modinfo.add_mod(mod_object.__name__, (None, %22%22, %22%22, %22%22
 , mo
@@ -1308,16 +1308,17 @@
 _object)
+)
 %0A%0A# Afte
@@ -1398,24 +1398,29 @@
 od_name, mod
+_data
  in modinfo.
@@ -1439,24 +1439,48 @@
 teritems():%0A
+    if mod_data%5B0%5D:%0A    
     print(%22C
@@ -1519,19 +1519,31 @@
 e))%0A    
-mod
+    mod_data%5B0%5D
 .mod_com

Fix legacy mod detection