Script structure

Set your editor to use 4 character wide tabs. Spaces should never be used to tabulate lines.
Instead, use spaces to adjust expressions to each other inline.

The maximum length of the lines is 120 characters.
Statements shouldn’t even get close to this number.
In case they do, you get a warning.

All file name references are case sensitive in scripts, the extensions accordingly.

Values used multiple times should be calculated directly before the block of usage if it can be well localized or at the beginning of the script otherwise. There is no compromise.
Calculate complex values only once to spare calculation time by storing them in variables (but do not waste variables unnecessary) or in the transformation stack (add, rot, etc.).

The object scripts are linear which makes them clearer.
Subroutines should only break it when a calculation or model generation segment is needed more than once, or for script readability.
Avoiding coding the same thing twice is an important principle in all programming languages.
Redundancy makes later changes a lot more difficult.

Try not to use huge choice branches, instead prepare the data for a calculation or generation command in smaller choice-blocks, where you can avoid redundancy easier.

Bad solution

if bOnHomeStory then
    line_type ltContour
    fill gs_fill_type
    poly2_b 5, 3, gs_fill_pen, gs_back_pen,
        left,   0,      1,
        left,   -depth, 1,
        right,  -depth, 1,
        right,  0,      0,
        left,   0,     -1
endif
if (bOnUpperStory or bOnAboveUpper) and bDrawContBB then
    line_type ltBelow
    fill fillTypeBelow
    poly2_b 5, 3, fillPenBelow, fillBackBelow,
        left,   0,      1,
        left,   -depth, 1,
        right,  -depth, 1,
        right,  0,      0,
        left,   0,     -1
endif

The definition of geometry is duplicated!
It could be even worse if the distance between the identical commands were bigger.

Good solution

if bOnHomeStory then
    bPolygon = 1
    line_type ltContour
    fill gs_fill_type
    fillPen = gs_fill_pen
    fillBGPen = gs_back_pen
endif
if (bOnUpperStory or bOnAboveUpper) and bDrawContBB then
    bPolygon = 1
    line_type ltBelow
    fill fillTypeBelow
    fillPen = fillPenBelow
    fillBGPen = fillBackBelow
endif
if bPolygon then
    poly2_b 5, 3, fillPen, fillBGPen,
        left,   0,      1,
        left,   -depth, 1,
        right,  -depth, 1,
        right,  0,      0,
        left,   0,     -1
endif

Prepare your scripts for localization.
Use “asdf” for non-localized strings (e.g. macro calls) and _(`asdf`) for localized strings (e.g. string constants, parameter values).

Compatibility: Using special quotes to indicate localized strings e.g. `asdf` is Deprecated.