Extending shipped scripts
CompilesWhen a shipped script does almost what you want, inherit from it instead of copying it. See Inheritance for how it works; these are the patterns.
The same thing, with a new setting
Section titled “The same thing, with a new setting”super "/data/catch/scripts/utility/entity_mover/entity_mover_rotate.vscript"
// A new setting, next to the parent's.let wobble_degrees: float = 5.0Change one behaviour
Section titled “Change one behaviour”Replace a virtual function with an override. Here a new setting can pause the spinning; when it isn’t paused,
super:: runs the parent’s version unchanged:
super "/data/catch/scripts/utility/entity_mover/entity_mover_rotate.vscript"
// Stop spinning without removing the component.let paused: bool = false
override fn update_rotation() { if paused { return } super::update_rotation()}Add to an event
Section titled “Add to an event”Redefine the event and call the parent’s first, so it still sets itself up:
super "/data/catch/scripts/utility/entity_mover/entity_mover_rotate.vscript"
event export fn created() { super::created() $debug.print_line("[my_rotator] ready", null, false)}Finding what you can override
Section titled “Finding what you can override”Open the parent’s source in your editor and look for virtual fn. Those are the hooks the parent was built to let
children change. Its let settings appear in the level editor for your script as well, so you rarely need to
redeclare anything.
The spinning bobber is a complete example.