MSUTeam / MSU

Modding Standards and Utilities for Battle Brothers
21 stars 4 forks source link

[REQUEST] new requireUnsigned type checker #335

Open Darxo opened 7 months ago

Darxo commented 7 months ago

Is your feature request related to a problem? Please describe. requireInt is a universal typechecker but it does not go far enough for certain situations. The very typical variable type unsigned is not currently covered by a type checker in MSU

Describe the solution you'd like Add a new requireUnsigned function that would look like the following

::MSU.requireUnsigned <- function( ... )
{
    ::MSU.requireInt(vargv);
    foreach (value in vargv)
    {
        if (value < 0)
        {
            ::logError(value + " must have the type: unsigned");
            throw ::MSU.Exception.InvalidType(value);
        }
    }
}

Additional context This is the situation where I currently need such a function in my code.

image