# Advanced: Storing Scripts

Midbattle hashes can be quite long and complex. Because of this, sometimes It's simply impractical to include the entire thing in the <mark style="background-color:green;">"midbattleScript"</mark> Battle Rule in an event. To address this, I've created a secondary way of implementing a midbattle script by simply using a symbol ID to refer to an entire hash. This is done by instead creating the entire hash in the plugin scripts themselves. This can be done by using the `MidbattleScripts` module.

In the Deluxe Battle Kit plugin scripts, create a new script file (in the `RB` format, like the rest of the plugin scripts) and name this new file whatever you want. You can install [**Notepad++**](https://notepad-plus-plus.org/) for these types of files, if you don't already have a program that recognizes this format. In here, create a module called `MidbattleScripts`. Inside this module, you can save as many midbattle hashes as you want as constants, which you can then call upon as a shortcut to that midbattle hash without having to include the entire thing in a battle rule. This allows you to make as long of a script as you want without having to worry about cramming each event with enormous scripts.\
\
For example, say your custom file contained this script:

```
module MidbattleScripts
  MIDBATTLE_EXAMPLE_SCRIPT = {
    "RoundStartCommand_1_foe" => {
      "speech" => "You're not gonna beat me this time!"
    },
    "BattleEndLose" => {
      "speech" => "See? I told you!"
    },
    "BattleEndWin" => {
      "speech" => "No! Impossible!"
    }
  }
end
```

The constant used here is named `MIDBATTLE_EXAMPLE_SCRIPT`, but you may name this whatever you wish, as long as it's unique and doesn't overlap with an existing constant within this module. Once your constant is saved, you can then call it within the <mark style="background-color:green;">"midbattleScript"</mark> Battle Rule instead of inputting the entire hash, like so:

```
setBattleRule("midbattleScript", :MIDBATTLE_EXAMPLE_SCRIPT)
```

Note that when the constant is entered in the battle rule, it needs to be entered as a symbol, meaning it requires a semi-colon in front. It shouldn't have this when entered in the module.

You can use this method to make very long and intricate midbattle hashes without having to worry about space in the event scripts. If you want more intricate examples of midbattle scripts that utilize this feature, check the plugin file `[002] Midbattle Scripting/[003] MidbattleScripts Module`.


---

# 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://lucidious89-tutorials.gitbook.io/deluxe-battle-kit-tutorial/deluxe-battle-kit-for-v21.1/mid-battle-scripting/advanced-scripting/advanced-storing-scripts.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.
