def loadProfile(name): fileName = roplus.getWorkingDirectory( ) + "\\Profiles\\" + name + ".grinder" file = open(fileName, "r") result = json.loads(file.read()) file.close() return result
def getProfiles(): result = [] profilesPattern = roplus.getWorkingDirectory() + "\\Profiles" for file in os.listdir(profilesPattern): if file.endswith(".grinder"): result.append(file[:-8]) return result
def loadSettings(name): try: fileName = roplus.getWorkingDirectory() + "\\Settings\\" + name + ".json" file = open(fileName, "r") result = json.loads(file.read()) file.close() return result except Exception: return defaultSettings()
def reloadCombatModules(): global LOADED_COMBATS LOADED_COMBATS = {} dir_path = roplus.getWorkingDirectory() + "\\Combats" for file in os.listdir(dir_path): if file.endswith(".py") and not file.startswith("__"): filePath = os.path.join(dir_path, file) mod_name = "Combats." + file try: combatmod = imp.load_source(mod_name, filePath) if combatmod and hasattr(combatmod, "Combat"): try: combat_inst = combatmod.Combat() LOADED_COMBATS[combat_inst.name] = combat_inst roplus.log("Combat script loaded : {0} ({1})".format( combat_inst.name, combat_inst.author)) except: roplus.log( "Unable to create Combat() class from file : " + file) except: roplus.log("Unable to load file : " + file)
def saveProfile(profile): fileName = roplus.getWorkingDirectory( ) + "\\Profiles\\" + profile["name"] + ".grinder" file = open(fileName, "w") file.write(json.dumps(profile, indent=4)) file.close()
def saveSettings(s, name): fileName = roplus.getWorkingDirectory() + "\\Settings\\" + name + ".json" file = open(fileName, "w") file.write(json.dumps(s, indent=4)) file.close()