def set_active_sim(first_name='', last_name='', _connection=None): output = commands.CheatOutput(_connection) try: if _connection is None: output('SetActiveSim; Status:ParamError') return False tgt_client = services.client_manager().get(_connection) if tgt_client is None: output('SetActiveSim; Status:ClientError no client') return False sim_info = (services.sim_info_manager().get_sim_info_by_name( first_name, last_name)) if sim_info is None: output('SetActiveSim; Status:SimError no sim with this name found') return False SelectionGroupService \ .get(services.active_household_id()) \ .make_sim_selectable(sim_info) if tgt_client.set_active_sim_by_id(sim_info.id): output('SetActiveSim; Status:Success') return True output('SetActiveSim; Status:NoChange') return True except BaseException as exception: output('Error: {}'.format(exception)) Logger.log(traceback.format_exc())
def _TakePill ( targetSimHandler: argument_helpers.RequiredTargetParam, pillsObjectHandler: argument_helpers.RequiredTargetParam, requiresPill: bool = True, removePill: bool = True, showGeneralFeedback: bool = True, _connection: int = None) -> None: try: targetSimInfo = targetSimHandler.get_target(services.sim_info_manager()) if not isinstance(targetSimInfo, sim_info.SimInfo): raise ValueError("Failed to get the target sim, %s is not a valid sim id." % targetSimHandler.target_id) pillsObject = services.inventory_manager().get(pillsObjectHandler.target_id) # type: typing.Optional[script_object.ScriptObject] if pillsObject is None: pillsObject = services.object_manager().get(pillsObjectHandler.target_id) # type: typing.Optional[script_object.ScriptObject] if not isinstance(pillsObject, script_object.ScriptObject): raise ValueError("Failed to get the pills object, %s is not a valid script object id." % targetSimHandler.target_id) SafetyEmergencyContraceptivePill.TakePill(targetSimInfo, pillsObject = pillsObject, requiresPill = requiresPill, removePill = removePill, showGeneralFeedback = showGeneralFeedback) except: output = commands.CheatOutput(_connection) output("Failed to run the take pill command for the target sim.") Debug.Log("Failed to run the take pill command for the target sim.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__)
def _Help(_connection: int = None) -> None: try: helpText = "" for consoleCommand in _consoleCommands: # type: ConsoleCommand if not consoleCommand.ShowHelp: continue if len(helpText) != 0: helpText += "\n" if consoleCommand.HelpInput is not None: helpText += consoleCommand.Alias[ consoleCommand. HelpAliasPosition] + " " + consoleCommand.HelpInput else: helpText += consoleCommand.Alias[ consoleCommand.HelpAliasPosition] commands.cheat_output(helpText + "\n", _connection) except Exception as e: output = commands.CheatOutput(_connection) output("Failed to show help information.") Debug.Log("Failed to show help information.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__, exception=e)
def _Enable(targetSimHandler: argument_helpers.RequiredTargetParam, _connection: int = None) -> None: try: targetSimInfo = targetSimHandler.get_target( services.sim_info_manager()) if not isinstance(targetSimInfo, sim_info.SimInfo): raise ValueError( "Failed to get the target sim, %s is not a valid sim id." % targetSimHandler.target_id) dotInformation = Dot.GetDotInformation( targetSimInfo) # type: typing.Optional[Dot.DotInformation] if dotInformation is None: raise Exception( "Missing dot information object for a sim with the id %s." % targetSimInfo.id) dotInformation.Enabled = True except: output = commands.CheatOutput(_connection) output("Failed to enable the dot app on the target sim's phone.") Debug.Log("Failed to enable the dot app on the target sim's phone.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__)
def get_selectable_sims(_connection=None): output = commands.CheatOutput(_connection) tgt_client = services.client_manager().get(_connection) for sim_info in tgt_client.selectable_sims: output("sim {} {} is selectable".format(sim_info.first_name, sim_info.last_name))
def _SupportNeonOcean (_connection: int = None) -> None: try: Generic.ShowOpenBrowserDialog(Websites.GetNOSupportURL()) except: output = commands.CheatOutput(_connection) output("Failed to show the support site with the open browser dialog.") Debug.Log("Failed to show the support site with the open browser dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__)
def _ShowSelectSaveDialog (_connection: int = None) -> None: try: SelectSave.ShowSelectSaveDialog() except Exception as e: output = commands.CheatOutput(_connection) output("Failed to show the select save dialog.") Debug.Log("Failed to show the select save dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, exception = e)
def _Reset (_connection: int = None) -> None: try: Resetting.ShowResetDialog(This.Mod) except Exception as e: output = commands.CheatOutput(_connection) output("Failed to show reset dialog.") Debug.Log("Failed to show reset dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__, exception = e)
def _AboutMod (_connection: int = None) -> None: try: Generic.ShowAboutModDialog(This.Mod) except: output = commands.CheatOutput(_connection) output("Failed to show the about mod dialog.") Debug.Log("Failed to show the about mod dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__)
def _VisitModPage (_connection: int = None) -> None: try: Generic.ShowOpenBrowserDialog(Websites.GetNOMainModURL(This.Mod)) except: output = commands.CheatOutput(_connection) output("Failed to show the mod page with the open browser dialog.") Debug.Log("Failed to show the mod page with the open browser dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group = This.Mod.Namespace, owner = __name__)
def log_sim_info(_connection=None): output = commands.CheatOutput(_connection) tgt_client = services.client_manager().get(_connection) sim_info = tgt_client.active_sim_info sim_info.log_sim_info(output) output('commodity_tracker: {}'.format(sim_info.commodity_tracker)) output('commodity_tracker_lod: {}'.format( sim_info.commodity_tracker.simulation_level)) output('is npc: {}'.format(sim_info.is_npc)) output('is_selected: {}'.format(sim_info.is_selected)) output('is_selectable: {}'.format(sim_info.is_selectable)) output('can away actions: {}'.format( sim_info.away_action_tracker.is_sim_info_valid_to_run_away_actions()))
def dialogCallback(closedDialog: ui_dialog.UiDialog) -> None: try: if closedDialog.response == gameUserDataReportResponseID: Reporting.PrepareReportFiles(gameUserDataReportFilePath) _ShowReportCreatedDialog() elif closedDialog.response == desktopReportResponseID: Reporting.PrepareReportFiles(desktopReportFilePath) _ShowReportCreatedDialog() except: commands.CheatOutput( _connection )("Failed to run the callback for the prepare report location dialog." ) Debug.Log( "Failed to run the callback for the prepare report location dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__)
def _ShowFertilityNotificationsEnabledNotification( targetSimHandler: argument_helpers.RequiredTargetParam, _connection: int = None) -> None: try: targetSimInfo = targetSimHandler.get_target( services.sim_info_manager()) UIDot.ShowFertilityNotificationsEnabledNotification(targetSimInfo) except: output = commands.CheatOutput(_connection) output( "Failed to show the dot app's fertility notifications enabled notification." ) Debug.Log( "Failed to show the dot app's fertility notifications enabled notification.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__)
def _ShowTestResults(targetSimHandler: argument_helpers.RequiredTargetParam, _connection: int = None) -> None: try: targetSimInfo = targetSimHandler.get_target( services.sim_info_manager()) if not isinstance(targetSimInfo, sim_info.SimInfo): raise ValueError( "Failed to get the target sim, %s is not a valid sim id." % targetSimHandler.target_id) UIPregnancyTest.ShowTestResultNotification(targetSimInfo) except: output = commands.CheatOutput(_connection) output( "Failed to show the pregnancy test results notification for the target sim." ) Debug.Log( "Failed to show the pregnancy test results notification for the target sim.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__)
def canys_get_version_command(_connection=None): output = commands.CheatOutput(_connection) version = control_any_sim.__version__ output('you are currently running version {} of Control Any Sim'.format( version))
def _ShowPrepareReportLocationDialog(_connection: int = None) -> None: try: reportFileName = "NeonOcean Sims 4 Bug Report.zip" # type: str dialogResponses = list( ) # type: typing.List[ui_dialog.UiDialogResponse] gameUserDataDirectoryPath = Paths.UserDataPath # type: str gameUserDataReportFilePath = os.path.join(gameUserDataDirectoryPath, reportFileName) # type: str gameUserDataReportResponseID = 1 # type: int if os.path.exists(gameUserDataDirectoryPath): gameUserDataResponseArguments = { "dialog_response_id": gameUserDataReportResponseID, "sort_order": -2, "text": PrepareReportLocationDialogGameUserDataButton. GetCallableLocalizationString() } dialogResponses.append( ui_dialog.UiDialogResponse(**gameUserDataResponseArguments)) else: raise Exception("The game's user data path does not exist.") desktopDirectoryPath = os.path.expanduser("~/Desktop") # type: str desktopReportFilePath = os.path.join(desktopDirectoryPath, reportFileName) # type: str desktopReportResponseID = 2 # type: int if os.path.exists(desktopDirectoryPath): desktopResponseArguments = { "dialog_response_id": desktopReportResponseID, "sort_order": -2, "text": PrepareReportLocationDialogDesktopButton. GetCallableLocalizationString() } dialogResponses.append( ui_dialog.UiDialogResponse(**desktopResponseArguments)) dialogArguments = { "title": PrepareReportLocationDialogTitle.GetCallableLocalizationString(), "text": PrepareReportLocationDialogText.GetCallableLocalizationString(), "text_ok": PrepareReportLocationDialogCancelButton. GetCallableLocalizationString(), "ui_responses": dialogResponses } def dialogCallback(closedDialog: ui_dialog.UiDialog) -> None: try: if closedDialog.response == gameUserDataReportResponseID: Reporting.PrepareReportFiles(gameUserDataReportFilePath) _ShowReportCreatedDialog() elif closedDialog.response == desktopReportResponseID: Reporting.PrepareReportFiles(desktopReportFilePath) _ShowReportCreatedDialog() except: commands.CheatOutput( _connection )("Failed to run the callback for the prepare report location dialog." ) Debug.Log( "Failed to run the callback for the prepare report location dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__) Dialogs.ShowOkDialog(callback=dialogCallback, queue=False, **dialogArguments) except: commands.CheatOutput(_connection)( "Failed to show the prepare report location dialog.") Debug.Log("Failed to show the prepare report location dialog.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__)
def _AddUnpackedWickedWhimsCondoms( targetSimHandler: argument_helpers.RequiredTargetParam, unpackedObject: argument_helpers.RequiredTargetParam, _connection: int = None) -> None: try: if not WickedWhims.ModInstalled(): raise Exception("WickedWhims is not installed.") if len(WickedWhimsCondomDefinitionIDs) == 0: raise Exception( "Cannot add WickedWhims condoms while the condom definitions list is empty." ) targetSimInfo = targetSimHandler.get_target(services.sim_info_manager( )) # type: typing.Optional[sim_info.SimInfo] if not isinstance(targetSimInfo, sim_info.SimInfo): raise ValueError( "Failed to get the target sim, %s is not a valid sim id." % targetSimHandler.target_id) targetSim = targetSimInfo.get_sim_instance() # type: sim.Sim if targetSim is None: raise Exception( "Cannot add condoms to the inventory of a sim that is not instanced." ) unpackedObject = unpackedObject.get_target( ) # type: typing.Optional[script_object.ScriptObject] if not isinstance(unpackedObject, script_object.ScriptObject): raise ValueError( "Failed to get the unpacked object, %s is not a valid object id." % unpackedObject.target_id) condomCountStatisticType = services.get_instance_manager( resources.Types.STATISTIC ).get(CondomBoxCountStatisticID, None) # type: typing.Optional[typing.Type[statistic.Statistic]] if condomCountStatisticType is None: raise ValueError( "Failed to get the condom count statistic type, %s is not a valid statistic id." % CondomBoxCountStatisticID) condomCountStatisticTracker = unpackedObject.get_tracker( condomCountStatisticType) if condomCountStatisticTracker is None: raise Exception( "Could not find an appropriate condom count statistic tracker in the unpacked object." ) condomCountStatistic = condomCountStatisticTracker.get_statistic( condomCountStatisticType, add=True) # type: statistic.Statistic condomCount = condomCountStatistic.get_value() # type: int targetSimInventoryComponent = targetSim.inventory_component for condomIndex in range(condomCount): condomObject = system.create_object( random.choice(WickedWhimsCondomDefinitionIDs)) if condomObject is not None: targetSimInventoryComponent.player_try_add_object(condomObject) except: output = commands.CheatOutput(_connection) output("Failed to add WickedWhim's unpacked condom objects to a sim.") Debug.Log( "Failed to add WickedWhim's unpacked condom objects to a sim.", This.Mod.Namespace, Debug.LogLevels.Exception, group=This.Mod.Namespace, owner=__name__)