HPL3/SOMA/Getting Started/Add Your First Script

From Frictional Wiki
Jump to navigation Jump to search

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

  1. Open MyFirstMod/maps/sample_map/sample_map.hps in your text editor.
  2. Find void OnStart() inside the cScrMap class.
  3. Add the debug-message call between its braces:
void OnStart()
{
    cLux_AddDebugMessage("Hello World!");
}
  1. Save the script.
  2. Launch the mod. If the map was already running in development mode, press F5 to reload it.

The text Hello World! should appear at the lower-left of the screen when the map starts.

Note icon.png Keep the generated includes, the 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.hpm and sample_map.hps.
  • Confirm the line ends with a semicolon and uses straight quotation marks.
  • Confirm you edited the script inside your copied mod.
  • Press F1 in 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.