Skip to content

Deploying the script

Gabor Barat edited this page Nov 5, 2020 · 3 revisions

Please note that later there will be release versions of the script which won't require you to use Visual Studio or MDK-SE for deployment. Although extending GridOS with your own modules and menu items is still best done in that environment.

If you wish to deploy the script – in other words, to run it in the game –, you have to use Visual Studio along with the MDK-SE plugin that was designed for this specific purpose.

This plugin takes care of aggregating all the files of the project into a single script file, and places it into the game's script folder to be selectable from the in-game script menu.

You can find the releases of MDK-SE here. Basically you have to download the latest release, and run the installer to install the tool.

Deploying using the integrated deploy test project

After you have the MDK-SE plugin set up, and opened the solution in Visual Studio:

  • Right-click on the GridOS.DeployTest project, and select the MDK Deploy Script command from the menu.
  • Later, if you wish to change the deployment settings, e.g. enable minifying:
    • Right-click the project, and select the MDK Script Options command.
    • Re-deploy the project after you changed the settings.
  • After deployment, open the Control Panel in the game, select a Programmable Block, open the code editor, select the Browse Scripts button, and select the script (GridOS.DeployTest) in the list.
  • Click OK to compile and start running the script.

Setting up controls in the game

See: Setting up in-game controls

Functionality included in the integrated deploy test project

If you look at the code in Program.cs, you can see that this simple deployment template does the following:

  • At startup, it:
    • Instantiates the GridOS class and stores it in a variable.
    • Registers a simple example module. This module:
      • adds a bunch of elements to the menu,
      • asks to update itself at a regular interval (and it changes some menu items when it's run).
    • Registers the programmable block's own integrated display as a screen used by GridOS.
      • It's important to register at least one screen, since without that GridOS cannot display anything.
      • You can register any LCDs in the system, including blocks that just contain LCDs, e.g. cockpits.
  • At each programmable block invocation:
    • The program's Main() method simply passes control over to GridOS.Main().

The above serves as a template to help you create your own scripts. For that, all you need to do is to create a new project in Visual Studio, using MDK-SE's Ingame Script template (for instructions, see the wiki of MDK-SE), right-click References in the project tree, and add a reference to the GridOS shared project.