Change a whole family of classes with one override
ShotScriptStroke Engine

Change a whole family of classes with one override

By ShotScript Team

Take a Graph made of Nodes and Edges, where a Node's ConnectTo makes the Edge between two Nodes. Now you want a graph whose Nodes carry a colour. Since Sunday, you write that in ShotScript as a family. scope ColoredGraph extends Graph starts a new family from Graph, and one override class ColoredGraph.Node changes the Node that every one of Graph's methods makes.

Graph itself sits in the system script. Its head is a bare scope Graph line, and each class in it is named through the head.

ReplicatedStorage/Graphs.shot
system script

scope Graph

class Graph.Node = {
	public Name : string

	constructor new(name : string)
		local self : Node = init()
		self.Name = name
		return self
	end

	public ConnectTo(other : Node) : Edge
		return Edge.new(self, other)
	end
}

class Graph.Edge = {
	public From : Node
	public To : Node

	constructor new(from : Node, to : Node)
		local self : Edge = init()
		self.From = from
		self.To = to
		return self
	end
}

return Graph

ColoredGraph's head sits in a script of its own under Graphs, with no use between the two. One override adds the colour.

ReplicatedStorage/Graphs/ColoredGraph.shot
system script.Parent

scope ColoredGraph extends Graph

override class ColoredGraph.Node extends super.Node = {
	public Color : string

	constructor new(name : string, color : string)
		local self : Node = init(super.new(name))
		self.Color = color
		return self
	end
}

return ColoredGraph

Graph's methods now make ColoredGraph's members, so when Graph's ConnectTo runs on a ColoredGraph Node, it makes a ColoredGraph Edge, and that Edge's From has a Color.

local a = ColoredGraph.Node.new("A", "red")
local b = ColoredGraph.Node.new("B", "blue")
local edge = a:ConnectTo(b)
local color : string = edge.From.Color

We never wrote ConnectTo a second time, and Graph never hears about the colours.

Since late Sunday, a family class may also extend another member of its own family. With class Widgets.Button extends Widget, one override class BoldWidgets.Widget restyles every BoldWidgets Button too, so BoldWidgets.Button.new():Paint() is "button on bold".

A generic <G : Graph> takes any family. Two families that extend one family keep their classes apart too. ColoredGraph.Edge.new takes and makes ColoredGraph's own Edge, and a BlueGraph Edge where a RedGraph Edge is wanted is an error.

Types follow the family too. Say Graph also holds a type, type Graph.Style = { Width : number }, and a class Graph.Wire with a field public Look : Style. When ColoredGraph adds a colour with override type ColoredGraph.Style extends super.Style = { Color : string }, the Wire it inherits from Graph takes ColoredGraph's Style as its Look. So ColoredGraph.Wire.new({ Width = 1 }) is an error, since its Look leaves out Color.

A family can spread over its system's scripts like this, but two family heads in one script are an error. Another system reads and extends a family through use script.Parent.Graph, and a Global's family needs no use in any system. Scopes that hold only types or sets aren't families, so two of them, written like scope Shapes, may share a script.

ShotScript Editor knows the family as well. Type ColoredGraph. and completion lists the family as extended, its own Node and the Edge it takes from Graph, as in the picture at the top. On a ColoredGraph Node, the signature card for a:ConnectTo( reads other : Node, with a ? only where the declaration has one.

That's the change we'd try first. Further down you'll find classes that get a constructor from their fields, bounds on type parameters, a signature tip that shows the line as declared, side-by-side Docs pages that read as one, keys that land where you meant, and copper that shines like copper in Stroke Engine. Classes has families in full, and New in ShotScript and New in Stroke Engine list every change.

Classes get a constructor from their fields

A class that writes no constructor now gets a new made from its fields.

class Point = {
	public X : number
	public Y : number

	public Sum() : number
		return self.X + self.Y
	end
}

Point.new(1, 2) takes the fields in the order you wrote them, and Point.new{ X = 1, Y = 2 } takes them by name. Point(1, 2) and Point{ X = 1, Y = 2 } are short for those two calls. A class like this that extends Shape counts in subclasses of Shape, since the new made from its fields makes its objects.

Inside a family, the short calls follow the object. In a Graph method run on a ColoredGraph object, Point{ X = 3 } and Point(1, 2) make ColoredGraph's Point, with its defaults.

Type parameters take bounds

A generic can take any type as its bound, a class included. In Strongest<T : Character>(list : { T }) : T, T has Character's members inside the body, and completion lists them there. When Mage extends Character, Strongest hands back a Mage for a list of Mages, and a list holding a Part is an error.

An interface works as a bound too, and a class fits it only by saying so. For T : Lerpable<T>, a class that writes implements Lerpable<T> passes, and a class with every member but no implements is an error. Having the right methods by luck doesn't count.

The signature tip shows the line you declared

A Luau script in the light theme. Line 3 declares the generic function pick, taking a and b of type T and returning T. On line 9 the caret sits in the empty second slot of a pick call, and the tip above it shows the declared line with the second parameter, b, in bold.
The tip keeps the declared line and bolds the empty slot you're in.

In a Luau script, type ( after a function name. The list shows at once, and the signature tip follows about half a second later. The tip shows the function as declared, like pick(a: T, b: T): T, with the parameter under the caret in bold. That holds for an empty slot, and for a variadic ...: T... too.

Side-by-side Docs pages read as one

Open two Docs pages side by side, and both halves now start their member docs at the same left edge, so the pair reads as one page cut in two. Both halves follow one rule for where a doc goes. A short member's doc stays beside it, the narrower half puts a too-wide member's doc under it, and a member whose signature wraps shows its long doc, wrapped, under its code.

Every overload's tag reads dim at the same left edge, and an overload's doc under its code starts with its tag on one line. A long doc under a parameter table starts at the parameter names.

Press the splitter between the halves of a widened pair, and the pair stays wide. Close it, and Docs gets its width back. Close a doc window opened beside Docs and open it beside once more, and both halves come back level at once, with no twitch.

Keys and clicks land where you meant

Press Ctrl+P, type a name and press Enter, then keep typing. Your letters land in the script you picked.

Type in a doc window, docked beside Docs or floating, then close it with its x and keep typing. Your letters land in the home Docs' Find. A slow close does the same, with the x held down or after a press on its title. Close a doc window's tab while Docs sits tabbed behind Properties, and no letter lands in a Properties filter, the Command Line or a script. After a Docs window's tab closes, your letters reach only the Docs you're in, never the Explorer search.

In a code tab, Ctrl+Up and Ctrl+Down do nothing, so the view and the caret stay put. With two or more carets, Page Up and Page Down do nothing either, so every caret stays where it is. Shift+Page Down and Shift+Page Up there scroll the view to the first caret you made. In Explorer, Shift+Page Down and Shift+Page Up leave the pick and the view as they were, while a plain Page Down pages.

In Properties, a click anywhere on a bool's value cell ticks or clears it, while a click on its name, or Space, changes nothing. Select Color on a Color3 property opens centred on Studio's window, where Studio's own opens.

Copper shines like copper in Stroke Engine

A hammered copper kettle with a silver handle, seen from above on a pebbled mat in a dim room, with Specular Tail off. The lid and the top of the body are nearly black, with small sharp highlights, and only the round lower body shows copper.Specular Tail offSpecular Tail on
The same kettle in the same light. Only Specular Tail changes.

Stroke Engine has a new Specular Tail setting that lets copper, brass and chrome spread their shine the way real metal does. Drag the line across the kettle and watch the lid come out of the dark.

The camera got more real on Sunday too. Mid grey now sits where a photo puts it, bright parts keep their detail over a stop longer before turning white, and the darkest parts stay as deep as a real camera keeps them, with mid tones unchanged. Parts of a shot outside the focus stay smoothly blurred after denoising, as a real lens shows them, and shots with a soft background now render in about the same time as sharp ones.

A flame or a lamp shape can now glow only to the camera, so it looks as bright as the real thing without lighting the room a second time. Fog, haze and films on glass can send light almost straight ahead, so sunlight through them gains a soft halo, and a thin layer of dust or haze on a window catches the sun and lights the room behind it.

And snow in the sun now glitters with countless tiny ice glints that stay put from frame to frame.