Skip to main content

Overview

field_accessor links a class field to the methods that read and write it. Go to definition on the field then lists the getter and setter too. It only affects navigation. The methods must be on the same class.

Syntax

Put it directly above the @field line.
  • Convention builds the method names from the field name: camelCase (getAge), PascalCase (GetAge) or snake_case (get_age). It defaults to camelCase.
  • Getter and setter name the methods directly and take precedence over the convention.

Example

Garry’s Mod methods are usually PascalCase:
Go to definition on vehicle.Speed now offers the field, GetSpeed and SetSpeed.