Command Services

Console Command

class CommonConsoleCommand(mod_identity, command_name, command_description, command_aliases=(), command_arguments=(), command_type=CommandType.Live, command_restriction_flags=CommandRestrictionFlags.UNRESTRICTED, required_pack_flags=None, console_type=None, show_with_help_command=True)

Bases: object

Used to indicate a command that can be run in the CTRL+SHIFT+C console.

Note

When a command is created, a Help command is also created for your Mod using the mod_identity.name (If it does not already exist) “<mod_name>.help”. Use this command to display all commands that have been registered using CommonConsoleCommand.

Note

To see an example command, run the command s4clib_testing.example_command in the in-game console.

Example usage:
@CommonConsoleCommand(ModInfo.get_identity(), 's4clib_testing.example_command', 'Print an example message', command_aliases=('s4clib_testing.examplecommand',), command_arguments=(CommonConsoleCommandArgument('thing_to_print', 'Text or Num', 'If specified, this value will be printed to the console. Default is "24".'),))
def _common_testing_do_example_command(output: Output, thing_to_print: str='24'):
    output(f'Here is what to print: {thing_to_print}')
Parameters:
  • mod_identity (CommonModIdentity) – The identity of the mod that owns this command.
  • command_name (str) – The name of the command. This name can be used to run this command in the console.
  • command_description (str) – Text that describes the purpose of this command and what it does.
  • command_aliases (Iterator[str], optional) – Alternative names for the command that can be used to run this command in the console. Default is no aliases.
  • command_arguments (Iterator[CommonConsoleCommandArgument], optional) – Command arguments that are used to describe details about the arguments of the command. Default is no arguments described.
  • command_type (CommandType, optional) – The type of command, most of the time you will want it to be CommandType.Live. Default is CommandType.Live.
  • command_restriction_flags (CommandRestrictionFlags, optional) – Flags that indicate restrictions of the command. Default is CommandRestrictionFlags.UNRESTRICTED.
  • required_pack_flags (Pack, optional) – Flags to indicate what Game Packs are required in order for this command to be available. If set to None, no Game Packs will be required to run this command. Default is None.
  • console_type (CommandType, optional) – The type of console the command may be run in. If set to None, the default console will be used. Default is None.
  • show_with_help_command (bool, optional) – If True, this command will appear when a player does “<mod_name>.help”. If False, it will not appear when a player does “<mod_name>.help” but will still appear when they do “<mod_name>.help <command>”. Default is True.
arguments

The arguments of the command.

Console Command Argument

class CommonConsoleCommandArgument(arg_name, arg_type_name, arg_description, is_optional=False, default_value=None)

Bases: object

An object that describes details about an argument that is used in a command.

Parameters:
  • arg_name (str) – A name to display for the argument.
  • arg_type_name (str) – Text to display that represents the type of the argument.
  • arg_description (str) – Text that describes what the argument is for.
  • is_optional (bool, optional) – Whether or not the argument is optional or required to be specified in the command. Default is False.
  • default_value (Any, optional) – If the argument is optional, this is the default value that will be used for the argument. Default is None.

Console Command Required Argument

class CommonConsoleCommandRequiredArgument(arg_name, arg_type_name, arg_description)

Bases: sims4communitylib.services.commands.common_console_command.CommonConsoleCommandArgument

An object that describes details about a Required argument that is used in a command.

Parameters:
  • arg_name (str) – A name to display for the argument.
  • arg_type_name (str) – Text to display that represents the type of the argument.
  • arg_description (str) – Text that describes what the argument is for.

Console Command Optional Argument

class CommonConsoleCommandOptionalArgument(arg_name, arg_type_name, arg_description, default_value)

Bases: sims4communitylib.services.commands.common_console_command.CommonConsoleCommandArgument

An object that describes details about an Optional argument that is used in a command.

Parameters:
  • arg_name (str) – A name to display for the argument.
  • arg_type_name (str) – Text to display that represents the type of the argument.
  • arg_description (str) – Text that describes what the argument is for.
  • default_value (Any) – This is the default value that will be used for the argument.

Console Command Output

class CommonConsoleCommandOutput(*args, **kwargs)

Bases: sphinx.ext.autodoc.importer._MockObject

An output object used when writing text to the console.

connection

The connection id to the console.

get_object(target)

Retrieve an instance of a Game Object referenced by an OptionalTargetParam or RequiredTargetParam.

Parameters:target (Union[OptionalTargetParam, RequiredTargetParam]) – A target param.
Returns:An instance of the Sim that matches the target or None if not found.
Return type:Union[Sim, None]
get_sim(target)

Retrieve an instance of a Sim referenced by an OptionalTargetParam or RequiredTargetParam.

Parameters:target (Union[OptionalTargetParam, RequiredTargetParam]) – A target param.
Returns:An instance of the Sim that matches the target or None if not found.
Return type:Union[Sim, None]