Skip to content

Extending shipped scripts

Compiles

When 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.

super "/data/catch/scripts/utility/entity_mover/entity_mover_rotate.vscript"
// A new setting, next to the parent's.
let wobble_degrees: float = 5.0

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()
}

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)
}

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.