To make Local scripts load properly in the track_designer GameMode, you'll need to modify the script loading logic in the OpenRCT2 repository. This involves identifying where the game determines which scripts (e.g., Local or Global) are loaded based on the GameMode, and updating that logic to include Local scripts for the track_designer mode.
Steps to Modify the Script Loading Behavior
Locate where scripts are loaded in the codebase
OpenRCT2 uses scripts for various gameplay modes, and their loading behavior is typically defined in the GameMode initialization logic or specific script-handling functions. Based on the provided context, focus on the GameMode logic or script-related handlers.
Identify the GameMode logic
The track_designer GameMode is likely initialized somewhere in the code. Look for references where track_designer is explicitly mentioned or where GameModes are defined and their behavior is configured.
Add support for Local scripts in the track_designer GameMode
Modify the part of the code that determines which scripts should be loaded for a GameMode. Ensure that Local scripts are included when the track_designer GameMode is active.
Testing the behavior
After making the changes, test the game in track_designer mode to confirm that Local scripts are now properly loaded.
Example Code Changes (Hypothetical)
Although specific files or functions for script loading are not provided, here’s a general idea of what the changes might look like:
A. Define Local Script Loading for the track_designer Mode
In the function or module that determines what scripts to load, locate the condition for track_designer. For example:
cpp
if (gameMode == GameMode::track_designer)
{
// Load only Global scripts by default
LoadGlobalScripts();
// Add loading logic for Local scripts
LoadLocalScripts();
}
B. Function to Load Local Scripts
Ensure you have a function that loads Local scripts. If it doesn’t already exist, you might need to implement it. For example:
cpp
void LoadLocalScripts()
{
for (const auto& scriptPath : GetLocalScriptPaths())
{
if (IsValidScript(scriptPath))
{
// Load the script into the game
LoadScript(scriptPath);
}
}
}
C. Check for Local Scripts in the Script Initialization Logic
In the script initialization logic, ensure that Local scripts are considered when the track_designer mode is active. For example:
cpp
switch (gameMode)
{
case GameMode::park:
LoadGlobalScripts();
break;
case GameMode::track_designer:
LoadGlobalScripts();
LoadLocalScripts(); // Add Local script support here
break;
case GameMode::scenario_editor:
LoadGlobalScripts();
break;
default:
break;
}
Relevant Areas to Investigate in the Codebase
GameMode Definitions
Look for files or functions defining game modes (track_designer, park, scenario_editor, etc.). These are likely where the script behavior is configured.
Script Loading Functions
Functions related to script handling, such as LoadScript(), LoadGlobalScripts(), and LoadLocalScripts(), are key candidates for modification.
Script Type Logic
If script types (Global, Local) are explicitly defined somewhere (e.g., enums or constants), ensure Local is properly included for track_designer.
Testing Files
After making the changes, verify by testing track_designer mode with Local scripts to ensure they are properly loaded and functioning as expected.
Notes
No Direct References to Script Loading in the Provided Context
The context provided does not include details about how the game loads scripts, so you may need to search the OpenRCT2 repository for keywords like script, LoadScript, or GameMode.
Testing is Critical
Ensure the changes don’t introduce regressions in other GameModes or script types. Test thoroughly.
By following the above steps, you should be able to modify the game to properly load Local scripts in the track_designer GameMode.