Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "exporting_pcks" page to change our stance about mods and pcks #10355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 43 additions & 16 deletions tutorials/export/exporting_pcks.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
.. _doc_exporting_pcks:

Exporting packs, patches, and mods
==================================
Exporting packs and patches
===========================

.. warning::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. warning::
.. danger::

Since the docs use warning for so many things, we should use danger for anything that is a legal, security, or data loss risk. See #10252.

We changed our stance about exporting mods using PCK files for security reasons.

**We don't recommend anymore using PCK files to add modding functionality to your game.**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**We don't recommend anymore using PCK files to add modding functionality to your game.**
**We no longer recommend using PCK files to add modding functionality to your game.**


Please read :ref:`doc_exporting_pcks_about_mods_using_pck_files` for more information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Please read :ref:`doc_exporting_pcks_about_mods_using_pck_files` for more information.
See :ref:`doc_exporting_pcks_about_mods_using_pck_files` for more information.

Standard phrasing, avoids imperative "read".


Use cases
---------
Expand All @@ -15,9 +22,11 @@ Examples of this include...
- Patches: the ability to fix a bug that is present in a shipped product.
- Mods: grant other people the ability to create content for one's game.

These tools help developers to extend their development beyond the initial
Godot offers some tools to help developers to extend their development beyond the initial
release.

.. _doc_exporting_pcks_overview_of_pck_files:

Overview of PCK files
---------------------

Expand All @@ -28,7 +37,7 @@ with extension ``.pck``).

- incremental updates/patches
- offer DLCs
- offer mod support
- offer mod support (see :ref:`doc_exporting_pcks_about_mods_using_pck_files` for more info)
- no source code disclosure needed for mods
- more modular project structure
- users don't have to replace the entire game
Expand All @@ -51,6 +60,23 @@ PCK files usually contain, but are not limited to:
The PCK files can even be an entirely different Godot project, which the
original game loads in at runtime.

.. _doc_exporting_pcks_about_mods_using_pck_files:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. UPDATE: Recommendation may change. If we ever implement sandboxing or another solution
.. change this section.

Recently we started using these kind of comments to keep track of information in the docs that is inherently likely to change.

About mods using PCK files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually headers are are either in the form "Using X for Y" or "Doing X with Y" or sometimes just "X", where X is the name of the feature. One of these suggestions is more idiomatic:

Suggested change
About mods using PCK files
Using PCK files for modding

or

Suggested change
About mods using PCK files
Using PCK files for mods

or

Suggested change
About mods using PCK files
Modding games with PCK files

or

Suggested change
About mods using PCK files
Supporting mods with PCK files

We should wait for other docs maintainers to comment before changing this. Note that the anchor and links to this section need to change, too.

--------------------------

While it's easy enough to create mods for a Godot game using PCK files, **we don't recommend doing it**.

The reason is simple: :ref:`PCK files are very powerful <doc_exporting_pcks_overview_of_pck_files>`. They can override and replace content in a Godot game.
While this seems ideal for modding purposes (and yes, it is), it comes with the downside of giving the keys to the castle to any bad actor.

While replacing shaders and models is quite benign, replacing scripts is problematic, as the GDScript scripting engine doesn't have actually
any concept of a `sandbox <https://en.wikipedia.org/wiki/Sandbox_(computer_security)>`__. Every mod containing GDScript files have access
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
any concept of a `sandbox <https://en.wikipedia.org/wiki/Sandbox_(computer_security)>`__. Every mod containing GDScript files have access
any concept of a `sandbox <https://en.wikipedia.org/wiki/Sandbox_(computer_security)>`__. Every mod containing GDScript files has access

to the entire Godot Engine API, including making network calls and accessing the filesystem.

We do currently encourage game developers to create their own modding system for the time being. To be really secure, any modding system
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We do currently encourage game developers to create their own modding system for the time being. To be really secure, any modding system
We do currently encourage game developers to create their own modding system. To be really secure, any modding system

No need to specify both "currently" and "for the time being".

We could also mention the criteria for no longer recommending this (presumably some implementation of sandboxing?), but I think that doing so is optional.

should limit the scope of scripting calls being made by a mod, as it may be compromised by an untrustworthy actor.

Generating PCK files
--------------------

Expand All @@ -66,7 +92,8 @@ process will build that type of file for the chosen platform.

.. note::

If one wishes to support mods for their game, they will need their users to
If one wishes to support mods for their game using PCK files, even after reading
:ref:`doc_exporting_pcks_about_mods_using_pck_files`, they will need their users to
create similarly exported files. Assuming the original game expects a
certain structure for the PCK's resources and/or a certain interface for
its scripts, then either...
Expand All @@ -90,39 +117,39 @@ Opening PCK files at runtime
----------------------------

To import a PCK file, one uses the ProjectSettings singleton. The following
example expects a “mod.pck” file in the directory of the games executable.
The PCK file contains a “mod_scene.tscn” test scene in its root.
example expects a ”dlc.pck” file in the directory of the games executable.
The PCK file contains a ”dlc_scene.tscn” test scene in its root.

.. tabs::
.. code-tab:: gdscript GDScript

func _your_function():
# This could fail if, for example, mod.pck cannot be found.
var success = ProjectSettings.load_resource_pack("res://mod.pck")
# This could fail if, for example, dlc.pck cannot be found.
var success = ProjectSettings.load_resource_pack("res://dlc.pck")

if success:
# Now one can use the assets as if they had them in the project from the start.
var imported_scene = load("res://mod_scene.tscn")
var imported_scene = load("res://dlc_scene.tscn")

.. code-tab:: csharp

private void YourFunction()
{
// This could fail if, for example, mod.pck cannot be found.
var success = ProjectSettings.LoadResourcePack("res://mod.pck");
// This could fail if, for example, dlc.pck cannot be found.
var success = ProjectSettings.LoadResourcePack("res://dlc.pck");

if (success)
{
// Now one can use the assets as if they had them in the project from the start.
var importedScene = (PackedScene)ResourceLoader.Load("res://mod_scene.tscn");
var importedScene = (PackedScene)ResourceLoader.Load("res://dlc_scene.tscn");
}
}

.. warning::

By default, if you import a file with the same file path/name as one you already have in your
project, the imported one will replace it. This is something to watch out for when
creating DLC or mods. You can solve this problem by using a tool that isolates mods to a specific mods subfolder.
creating DLCs. You can solve this problem by using a tool that isolates DLCs to a specific DLCs subfolder.
However, it is also a way of creating patches for one's own game. A
PCK file of this kind can fix the content of a previously loaded PCK.

Expand All @@ -132,12 +159,12 @@ The PCK file contains a “mod_scene.tscn” test scene in its root.
.. note::
For a C# project, you need to build the DLL and place it in the project directory first.
Then, before loading the resource pack, you need to load its DLL as follows:
``Assembly.LoadFile("mod.dll")``
``Assembly.LoadFile("dlc.dll")``

Summary
-------

This tutorial explains how to add mods, patches, or DLC to a game.
This tutorial explains how to add patches or DLCs to a game.
The most important thing is to identify how one plans to distribute future
content for their game and develop a workflow that is customized for that
purpose. Godot should make that process smooth regardless of which route a
Expand Down