Player Tool Handler

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Revision as of 14:11, 2 October 2026 by TiMan (talk | contribs) (Add a sourced SOMA guide with explanations and stock-script examples.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


The Player Tool Handler manages equipped tools and their HUD objects. Player_EquipTool selects a tool already in the inventory, Player_UnequipTool hides the current tool, and Player_RemoveTool removes a tool so it cannot be equipped again.

Before you start

  1. Open the map script inside your own mod. Keep its generated includes, cScrMap : iScrMap class and callback structure. See Add your first script if you have not edited a map script yet.
  2. Add the helper include shown below alongside the script’s other includes.
  3. Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.

Follow the stock example

#include "helpers/helper_player.hps"

Player_EquipTool

Tries to equip a specific tool in the player's inventory. Returns false if the tool isn't in the inventory.

Parameter Meaning
asTool the name of the tool entity to equip.
asLookEntities names of the entities (comma separated) that trigger the equipping of the tool when inside the camera view.

In maps/chapter04/04_02_tau_inside/04_02_tau_inside.hps, SOMA calls Player_EquipTool as follows.

Player_EquipTool("ARK");
Parameter Value in this stock call
asTool "ARK"

This is an excerpt from that stock script; its referenced names and variables belong to that script.

Player_UnequipTool

Unequips the currently carried tool.

Parameter Meaning
abRemoveFromInventory if tool should be removed from inventory when hidden. Defaults to false.

In maps/_e3/_e3_01_01/_e3_01_01.hps, SOMA calls Player_UnequipTool as follows.

Player_UnequipTool();

This is an excerpt from that stock script; its referenced names and variables belong to that script.

Player_RemoveTool

Removes the specified tool from the player's inventory so it can no longer be equipped.

Parameter Meaning
asTool the name of the tool entity to remove.

In maps/chapter05/05_01_phi_inside/05_01_phi_inside.hps, SOMA calls Player_RemoveTool as follows.

Player_RemoveTool("ARK");
Parameter Value in this stock call
asTool "ARK"

This is an excerpt from that stock script; its referenced names and variables belong to that script.

Check your change

Save the script and restart the map in development mode with F5. If the script fails, open F1 and use Show Error List or Show HPL Log. See the development loop for the launch and debugging steps.

See also