> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/scripting-cyberpunk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/scripting-cyberpunk/redscript/language-reference/scriptables.md).

# Scriptables

How to run your code along with the game.

Scriptables are singletons that load in the game with their own lifecycle in accordance to game events. As they're singletons, only one instance of them exist so you can opt to run your code with them instead of modifying or hooking into an existing class.

The game has a built-in class `ScriptableSystem` that has a lifecycle in regards to game sessions, but [Codeware](/scripting-cyberpunk/introduction/tools-and-frameworks/codeware.md) adds a new type of scriptable, `ScriptableService`, which is bounded with the game itself.

## RedScript's `ScriptableSystem`&#x20;

* Class in base Redscript
* Is bounded to game sessions (save)
  * Is created (attached) when loading a save
  * Is destroyed (detached) when unloading a save
* Can store things, `persistent` properties are saved in a game's save file and values can differ between saved

Example and documentation: [ScriptableSystem](/scripting-cyberpunk/redscript/language-reference/scriptables/scriptablesystem.md)

{% content-ref url="/pages/TRmcSa8PVpJj16gw77X8" %}
[ScriptableSystem](/scripting-cyberpunk/redscript/language-reference/scriptables/scriptablesystem.md)
{% endcontent-ref %}

## Codeware's `ScriptableService`

* Class added by [Codeware](https://www.nexusmods.com/cyberpunk2077/mods/7780) (cannot be used without Codeware).
* Independent of saves
  * Is created when starting the game and lives forever
  * Is destroyed when quitting the game
* Always runs with the game
* Can store things globally for all saves
  * `persistent` properties will be saved globally and will be same between saves
* Usually used for patching/modifying resources

Example and documentation: <https://github.com/psiberx/cp2077-codeware/wiki#lifecycle>

{% hint style="info" %}
Previously was named `ScriptableEnv`. Kept for backwards compatibility, do not use that name in new code.
{% endhint %}

{% content-ref url="/pages/DnHRvJGkaRcaVqxmfDUw" %}
[ScriptableService](/scripting-cyberpunk/redscript/language-reference/scriptables/scriptableservice.md)
{% endcontent-ref %}
