Skip to reading
Visual Scripting in Depth

37. Decide what should become a function

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView PDF page

A function is a named piece of reusable work. Parameters are the values a caller supplies: how many points, which object, whether an effect is enabled, or which text to use. A return value is the answer sent back.

Source table from 37. Decide what should become a function, page 41
Repeated workUseful parameters / result
Award pointsamount → amount awarded.
Show or hide a targettarget entity and visible flag → requested visibility.
Choose a responsetopic or state → selected reply ID.
Configure an effecttarget and strength → success/failure.
Test a puzzle requirementitem or condition → Boolean result.

Use a function when several events need the same behavior and should stay consistent. Copying six nodes into ten puzzles makes later fixes tedious. One well-named function can keep that shared work in one place.

Keep a function’s job narrow. Award Workshop Points should award points and return its amount. It should not quietly change the room, replace the GUI and start a dialogue unless that larger sequence is what its name promises.

Functions as Nodes is a definition system over real code or a real visual entry. The definition describes the work; it does not invent the function body.

Page 41 of 93Permalink
Go to page