Skip to content

Custom native extensions

Extensions add your own named methods to a native target type without adding a new built-in game operation.

  1. Create a utility class such as Player Actions and make it Static.
  2. Assign a Method definition to that class.
  3. In Method Settings, choose Extension Target → Target → Player.
  4. Declare parameters normally and use This Object in the body to call existing Player actions.
  5. Compile. Select the method under Custom Methods → Player Actions on a compatible Player receiver.

The definition is owned by the utility class and is static, but receives a typed This binding for its extension target. Callers use the receiver as the target object.

Extensions can target non-null native types including Entity, Player, Number, String, and fixed List/Dictionary types. Entity extensions also apply to compatible Player targets through native capability inheritance.

A Number/String receiver retains value semantics. A mutable object or collection receiver retains shared identity unless an input copy changes that graph. Extensions do not introduce new generic type parameters.

Methods can differ by parameters or extension target. For the same owner/name/parameters, a Player extension takes precedence over an Entity extension when the declared target is Player. Resolution uses declared types, so a generic Entity Variable does not automatically select Player-only behavior.

An identical built-in native signature takes precedence over a custom extension. Use a distinct name or a different parameter signature when you want the custom method to be independently selectable.

A SendScore Player extension can accept a Number, then call Send Message on This Object with a String such as Score: ${private.score}. Declare score as its parameter; the expression reads the call’s Private parameter, not a global score with the same name.