Difference between revisions of "HPL3/SOMA/Scripting/Highlight Effect Handler"

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Jump to navigation Jump to search
(Add a sourced SOMA guide with explanations and stock-script examples.)
 
(Expand the practical source walkthrough and clarify how to use the handler.)
 
Line 4: Line 4:
  
 
The stock tool script reads the HighlightActive instance variable. Its _Global_CanBeHighlighted returns that flag and supplies mBaseObj.GetID(); disabling that flag prevents this tool from being accepted by the handler.
 
The stock tool script reads the HighlightActive instance variable. Its _Global_CanBeHighlighted returns that flag and supplies mBaseObj.GetID(); disabling that flag prevents this tool from being accepted by the handler.
 +
 +
== Trace a tool’s highlight setting ==
 +
# Find <code>HighlightActive</code> in <code>editor/userclasses/EntityClasses.def</code>. The tool instance variable is a Boolean with a declared default of true; its description says it controls the highlight effect when the tool is looked at.
 +
# Open <code>script/props/Prop_Tool.hps</code>. The tool reads that instance variable into <code>mbHighlightActive</code> and returns it through the callback below.
 +
# Follow <code>UpdateAddObjects</code> in <code>script/modules/HighlightEffectHandler.hps</code>. It filters for selected stock script classes, requires a mesh and an on-screen entity, and skips entities whose measured light level is below <code>0.1</code>. A true tool flag therefore supplies eligibility; the handler still applies those additional checks.
  
 
== Stock tool eligibility callback ==
 
== Stock tool eligibility callback ==

Latest revision as of 14:32, 2 October 2026


The Highlight Effect Handler briefly sweeps a glow across eligible nearby objects. It scans active physics bodies, checks selected script classes and calls each entity’s _Global_CanBeHighlighted function. The response must supply a Boolean result and the entity ID in global argument 0. On-screen visibility and a minimum light level are also checked.

The stock tool script reads the HighlightActive instance variable. Its _Global_CanBeHighlighted returns that flag and supplies mBaseObj.GetID(); disabling that flag prevents this tool from being accepted by the handler.

Trace a tool’s highlight setting

  1. Find HighlightActive in editor/userclasses/EntityClasses.def. The tool instance variable is a Boolean with a declared default of true; its description says it controls the highlight effect when the tool is looked at.
  2. Open script/props/Prop_Tool.hps. The tool reads that instance variable into mbHighlightActive and returns it through the callback below.
  3. Follow UpdateAddObjects in script/modules/HighlightEffectHandler.hps. It filters for selected stock script classes, requires a mesh and an on-screen entity, and skips entities whose measured light level is below 0.1. A true tool flag therefore supplies eligibility; the handler still applies those additional checks.

Stock tool eligibility callback

void _Global_CanBeHighlighted()
{
    cScript_SetGlobalReturnBool(mbHighlightActive);
    cScript_SetGlobalArgID(0,mBaseObj.GetID());
}

See also