DE EN FR ES IT CZ

1. When a script is worth it

When a script is worth it

Ready made building blocks in a box, next to it a single special tool on a cloth

The most important rule first: what the editor can do, you build in the editor. Actions are visible, you can click and test them, and everybody on the team understands them. A script only becomes the better choice when the editor gets cumbersome.

SituationBetter in the editorBetter with Lua
A text, an animation, a scene changealwaysnever
A check in one place"If condition", "If value"
The same check in many placeswrite it once as a function, call it everywhere
Calculations, randomness with rules, going through liststediousa few lines
Reacting to the mouse wheel or certain keys throughout the gamepartly (key actions)event handler
Something should keep running in the backgroundevent handler, used sparingly

An example from Pia's cellar

Pia fiddles around with the grate. After the first wrong attempt she should just sigh, after the third she should give a clear hint. You can do that with action parts, but it needs a check of its own for every attempt. With a small function it is one line per place. You will build this function in chapter 5.

Rule to remember
Build in the editor first. Reach for a script when you click the same logic together for the third time.

Your task
Find a check in your project that you have already built several times. That is your first candidate for a script.