Reference › Function reference › Functions

Functions.values.isint

public

Call as

Functions.values.isint(num)

Record it as a dependency named Functions.values.isint (accepting the completion does this), then call it by that name.

What it does

Apply the legacy integer or canonical numeric-string spelling test. Numbers use floor equality; strings must equal the spelling obtained after numeric conversion and floor. Other types return false. This is not a finite-number validator.

Arguments

NameTypeWhat it does
numanyNumber or string to inspect; other types do not match.

Returns

1booleanWhether the original floor-equality or exact numeric-spelling predicate matches.

Editions

Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.

It reads no game API directly.

Example

local text = GetCVar("nameplateMaxDistance") or ""
return Functions.values.isint(text) and tonumber(text) >= 40

Dependencies

Source

Functions/values.lua, line 62. Read only in game; Duplicate makes an editable copy.

Functions.values.isint(num)
    if type(num) == "number" then
        return floor(num) == num
    elseif type(num) == "string" then
        local tmp = tonumber(num)
        if tmp ~= nil then
            return tostring(floor(tmp)) == num
        end
    end
    return false

Back to Function reference