Player Overview

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Jump to navigation Jump to search


The SOMA script declarations for this interface reference are in script/interfaces/Player_Interface.hps.

The player base exposes the native cLuxPlayer as mBaseObj and through GetBase. Player behavior and interaction states are separate scripts; player helpers can change the current state or install custom-control callbacks.

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_ChangeStateToCustomControls

Changes the player state so that the normal controls are used for something else.

Parameter Meaning
asLookInputCallback Overrides look controls. If false is returned, normal controls are overridden. Syntax: bool F(const cVector2f &in avLookAmount)
asMoveInputCallback Overrides move controls. If false is returned, normal controls are overridden. Syntax: bool F(const cVector2f &in avMoveAmount)
asActionInputCallback Overrides action input. If false is returned, normal controls are overridden. Syntax: bool F(int alAction, bool abPressed)
asLeanInputCallback Overrides lean input. If false is returned, normal controls are overridden. Syntax: bool F(float afAmount)

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

Player_ChangeStateToCustomControls("LoaderArm_Look", "LoaderArm_Move", "LoaderArm_Action", "LoaderArm_Lean");
Parameter Value in this stock call
asLookInputCallback "LoaderArm_Look"
asMoveInputCallback "LoaderArm_Move"
asActionInputCallback "LoaderArm_Action"
asLeanInputCallback "LoaderArm_Lean"

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

Player_ChangeStateToNormal

Sets the state of the player to normal

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