Galaxy - How to Script in Galaxy (Easily)

Tutorial by Sevion

Yes... It's finally here... A tutorial... From me... With a billion "..."'s...

Anyhow, let's get started.

No big titles, they're unnecessary <3

First, you should get your favorite text editor. Mine is Notepad++ for its easy syntax highlighting and other features.

(Note, if you use Notepad++, there will be syntax highlighting AND autocomplete attached to the bottom of this post! :3)

Next, you want to have your map opened to the Import Manager. Or whatever it's called... I never bothered to memorize the name of the window.

After you have that up, make a .galaxy file in your text editor (named WHATEVER YOU WANT with a .galaxy extension)

Once you have that, input this code:

//==================================================================================================
//
// <Your Map> MapScript
//
// Name:   <Your Map>
// Author: <Your Name>
//
//==================================================================================================
include "MainScript.galaxy"

//--------------------------------------------------------------------------------------------------
// Map Initialization
//--------------------------------------------------------------------------------------------------
void InitMap () {
    Main();
}


Yes, it NEEDS to be [ljass]"MainScript.galaxy"[/ljass] because it'll be used later on. Though, you CAN change it to whatever you want. Just remember to change the file name later on as well.

Now, for the later on... Make the MainScript.galaxy file and put in this:

//==================================================================================================
//
// <Your Map> MainScript
//
// Name:   <Your Map>
// Author: <Your Name>
//
//==================================================================================================
include "TriggerLibs/NativeLib"
include "Globals.galaxy"

//--------------------------------------------------------------------------------------------------
// Trigger: Initialization
//--------------------------------------------------------------------------------------------------

void InitTriggers() {
}

//--------------------------------------------------------------------------------------------------
// Library Initialization
//--------------------------------------------------------------------------------------------------
void InitLibs () {
    libNtve_InitLib();
}

//--------------------------------------------------------------------------------------------------
// Map Initialization
//--------------------------------------------------------------------------------------------------
void Main () {
    InitLibs();
    InitTriggers();
    InitGlobals();
}


Good! Now you have the file down! Next, make a Globals.galaxy file.

Put in this:

//==================================================================================================
//
// <Your Map> Globals
//
// Name:  <Your Map>
// Author: <Your Name>
//
//==================================================================================================
include "TriggerLibs/NativeLib"

//Objects

//Triggers

// Variables

//--------------------------------------------------------------------------------------------------
// Globals Initialization
//--------------------------------------------------------------------------------------------------
void InitGlobals () {
}


Good! All of your basic files are done!

After all of your basic files are done, you can now start scripting! Make your script file... I.E. if you want to SETUP your GAME, name it something like SetupGame.galaxy.

//==================================================================================================
//
// <Your Map> SetupGame
//
// Name:   <Your Map>
// Author: <Your Name>
//
//==================================================================================================
include "TriggerLibs/NativeLib"
include "Globals.galaxy"

bool SetupGame ( bool testConds, bool runActions ) {
    //Dew Stuffz
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText("I Has Init!");
}


Then, in the triggers section in Globals.galaxy, add your trigger:

//Triggers
trigger gt_SetupGame


Include the file in MainScript.galaxy:

//==================================================================================================
//
// <Your Map> MainScript
//
// Name:   <Your Map>
// Author: <Your Name>
//
//==================================================================================================
include "TriggerLibs/NativeLib"
include "Globals.galaxy"
include "SetupGame.galaxy"


Initialize it in MainScript.galaxy:

void InitTriggers () {
    gt_SetupGame = TriggerCreate(SetupGame);
    TriggerAddEventMapInit(gt_SetupGame)
}


Lastly, import them ALL into your map via Import Manager and rename the very FIRST script you made to MapScript.galaxy. Replace the existing one. Save. (Yes, you have to rename. It won't let you import files with reserved names but will let you rename to those.)

Yay! Now, all you have to do is script and be sure to initialize them in the script files. You don't HAVE to follow these conventions, but I like them and they're easy if you have a tabbed text editor (Notepad++!!!!).

Now, for my uber sexy highlighting and autocomplete:

Mini-Tutorial:

Download the attachment and un7z it. Place Galaxy.xml into $ProgramFiles$\Notepad++\Plugins\Apis\

Open Notepad++ and go to View -> User Defined Language Dialog.

Import a new language and select Galaxy Highlighting.xml.

I have some presets in there set to match the Dark Blue theme. Change the settings as you see fit, but for the love of God, don't change anything but colors.
Click here to comment on this tutorial.
Tutorials submitted by users are copyright of the original author. All other content on this site is copyright TheHelper.net.
Copyright is secured automatically upon creation, and does not require registration