# Persistence

The fields of classes that extend `ScriptableSystem` or `PersistentState` (e.g. `ScriptedPuppetPS`) can be declared with the **persistent** modifier to be persisted in game saves.

You can persist data of all types except for `String`, `Variant` and `ResRef` (and arrays of these types).

Instances of classes can be persisted too, but note that their fields must also be marked as **persistent**, or they won't be persisted and instead they'll be initialized with defaults.

```swift
module MyMod

public class Entry {
    // both of these will be persisted
    public persistent let related: TweakDBID;
    public persistent let lasting: Int32;
    // this won't be persisted
    public let temporary: Int32;
}

public class MySystem extends ScriptableSystem {
    private persistent let m_entries: array<ref<Entry>>;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.redmodding.org/redscript/references-and-examples/common-patterns/persistence.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
