37. Decide what should become a function
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.
| Repeated work | Useful parameters / result |
|---|---|
| Award points | amount → amount awarded. |
| Show or hide a target | target entity and visible flag → requested visibility. |
| Choose a response | topic or state → selected reply ID. |
| Configure an effect | target and strength → success/failure. |
| Test a puzzle requirement | item 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.
