Skip to content

Add min, max and clamp blocks to Operators #2285

@cshaa

Description

@cshaa

Requested feature

Functions min (returning the lowest of two values), max (returning the greatest of two values) and clamp (returning a value that is between two bounds, or the closest bound) should be included in the Options tab.

Block design

obrazek

Motivation

Any time you need to restrict a value (eg. player cannot leave a certain area, or ensuring maximal and minimal speed) these blocks would massively simplify the code. This is a code snippet I have used many times:
obrazek
And this is how it would look with the new clamp block:
obrazek

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions