Difference between revisions of "HPL3/SOMA/Getting Started/Add Your First Script"
< HPL3 | SOMA | Getting Started
Jump to navigation
Jump to search
(Created page with "{{Hpl3SomaGettingStarted|step=5}} Every map can have a map script. For the sample map, it is <code>sample_map.hps</code> beside <code>sample_map.hpm</code>. == Add a visible...") |
|||
| Line 3: | Line 3: | ||
Every map can have a map script. For the sample map, it is <code>sample_map.hps</code> beside <code>sample_map.hpm</code>. | Every map can have a map script. For the sample map, it is <code>sample_map.hps</code> beside <code>sample_map.hpm</code>. | ||
| − | + | {{note|It is highly recoomended to use Visual Studio Code with the HPL3 Language Tools extension for scripting.}} | |
| − | # Open <code>MyFirstMod/maps/sample_map/sample_map.hps</code> in your text editor. | + | ==Add a visible script change== |
| − | # Find <code>void OnStart()</code> inside the <code>cScrMap</code> class. | + | |
| − | # Add the debug-message call between its braces: | + | #Open <code>MyFirstMod/maps/sample_map/sample_map.hps</code> in your text editor. |
| + | #Find <code>void OnStart()</code> inside the <code>cScrMap</code> class. | ||
| + | #Add the debug-message call between its braces: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
| Line 16: | Line 18: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | # Save the script. | + | #Save the script. |
| − | # Launch the mod. If the map was already running in development mode, press <code>F5</code> to reload it. | + | #Launch the mod. If the map was already running in development mode, press <code>F5</code> to reload it. |
The text <code>Hello World!</code> should appear at the lower-left of the screen when the map starts. | The text <code>Hello World!</code> should appear at the lower-left of the screen when the map starts. | ||
| Line 23: | Line 25: | ||
{{note|Keep the generated includes, the <code>cScrMap : iScrMap</code> declaration, and the surrounding callback structure. This tutorial changes only the body of <code>OnStart()</code>.}} | {{note|Keep the generated includes, the <code>cScrMap : iScrMap</code> declaration, and the surrounding callback structure. This tutorial changes only the body of <code>OnStart()</code>.}} | ||
| − | == Checkpoint == | + | ==Checkpoint== |
Continue when the message appears in-game after a fresh map start. | Continue when the message appears in-game after a fresh map start. | ||
| − | == If it does not work == | + | ==If it does not work== |
| − | * Confirm the script has the same base name and folder as the map: <code>sample_map.hpm</code> and <code>sample_map.hps</code>. | + | *Confirm the script has the same base name and folder as the map: <code>sample_map.hpm</code> and <code>sample_map.hps</code>. |
| − | * Confirm the line ends with a semicolon and uses straight quotation marks. | + | *Confirm the line ends with a semicolon and uses straight quotation marks. |
| − | * Confirm you edited the script inside your copied mod. | + | *Confirm you edited the script inside your copied mod. |
| − | * Press <code>F1</code> in development mode, then use '''Show Error List''' or '''Show HPL Log'''. | + | *Press <code>F1</code> in development mode, then use '''Show Error List''' or '''Show HPL Log'''. |
Read [[HPL3/Scripting/Scripting Guide/Scripting Workflow and Structure|Scripting Workflow and Structure]] for the generated map-script layout and [[HPL3/Scripting/Scripting Guide/Hello World|Hello World]] for the focused scripting lesson. | Read [[HPL3/Scripting/Scripting Guide/Scripting Workflow and Structure|Scripting Workflow and Structure]] for the generated map-script layout and [[HPL3/Scripting/Scripting Guide/Hello World|Hello World]] for the focused scripting lesson. | ||
Latest revision as of 12:55, 31 August 2026
Every map can have a map script. For the sample map, it is sample_map.hps beside sample_map.hpm.
Add a visible script change
- Open
MyFirstMod/maps/sample_map/sample_map.hpsin your text editor. - Find
void OnStart()inside thecScrMapclass. - Add the debug-message call between its braces:
void OnStart()
{
cLux_AddDebugMessage("Hello World!");
}
- Save the script.
- Launch the mod. If the map was already running in development mode, press
F5to reload it.
The text Hello World! should appear at the lower-left of the screen when the map starts.
cScrMap : iScrMap declaration, and the surrounding callback structure. This tutorial changes only the body of OnStart().Checkpoint
Continue when the message appears in-game after a fresh map start.
If it does not work
- Confirm the script has the same base name and folder as the map:
sample_map.hpmandsample_map.hps. - Confirm the line ends with a semicolon and uses straight quotation marks.
- Confirm you edited the script inside your copied mod.
- Press
F1in development mode, then use Show Error List or Show HPL Log.
Read Scripting Workflow and Structure for the generated map-script layout and Hello World for the focused scripting lesson.