Skip to content

API CInt en

Codex edited this page Sep 23, 2026 · 1 revision

CInt

ClassicUO / Basic IDE

Home · API · Basic

Rounds a number to a whole value, for example a calculated delay or item limit.

Exact syntax

CInt(value:Any) -> Integer

Parameters

  • value — One required Integer/Decimal or numeric String. Text uses a dot and optional exponent, independent of UI language; "0x0EED" is not numeric text here. Invalid text, Array, Object and Unit become 0. Validate user input with IsNumeric before converting.

Returns

Integer, signed 32-bit: halves round away from zero, so 2.5 becomes 3 and -2.5 becomes -3. CInt and CLng have the same implementation; CLng does not create a 64-bit value. Use finite values whose rounded result is within -2147483648..2147483647. This is not a Boolean result.

Behavior

  • Local computation: no packet, target or game action. BasicDouble parses invariant floating-point text first. These are this engine’s rules; they are not identical to VB.NET conversions. Decimal stores a double, and CInt/CLng use midpoint-away-from-zero rounding.

Internal functions: from call to result

Local computation: no packet, target or game action. BasicDouble parses invariant floating-point text first. These are this engine’s rules; they are not identical to VB.NET conversions. Decimal stores a double, and CInt/CLng use midpoint-away-from-zero rounding.

1. BasicDouble

One required Integer/Decimal or numeric String. Text uses a dot and optional exponent, independent of UI language; "0x0EED" is not numeric text here. Invalid text, Array, Object and Unit become 0. Validate user input with IsNumeric before converting.

Decimal / double

Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionApi.cs; function BasicDouble.

2. Register

Rounds a number to a whole value, for example a calculated delay or item limit.

Integer, signed 32-bit: halves round away from zero, so 2.5 becomes 3 and -2.5 becomes -3. CInt and CLng have the same implementation; CLng does not create a 64-bit value. Use finite values whose rounded result is within -2147483648..2147483647. This is not a Boolean result.

Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionApi.cs; function Register.

Examples

CInt — 1

# CInt1
#
# Rounds a number to a whole value, for example a calculated delay or item limit.
#
# Integer, signed 32-bit: halves round away from zero, so 2.5 becomes 3 and -2.5 becomes -3.
# CInt and CLng have the same implementation; CLng does not create a 64-bit value. Use finite
# values whose rounded result is within -2147483648..2147483647. This is not a Boolean result.

SUB Main()
    # value=2.5. The half is rounded away from zero; Main returns Integer 3, not the
    # midpoint-to-even value 2.

    RETURN CInt(2.5)
END SUB

Parameter and execution notes:

  • value=2.5. The half is rounded away from zero; Main returns Integer 3, not the midpoint-to-even value 2.

CInt — 2

# CInt2
#
# Rounds a number to a whole value, for example a calculated delay or item limit.
#
# Integer, signed 32-bit: halves round away from zero, so 2.5 becomes 3 and -2.5 becomes -3.
# CInt and CLng have the same implementation; CLng does not create a 64-bit value. Use finite
# values whose rounded result is within -2147483648..2147483647. This is not a Boolean result.

SUB Main()
    # offset=-2.5 is a signed coordinate offset. Main returns -3. This example calculates an offset;
    # it does not move the character.

    VAR offset = -2.5
    RETURN CInt(offset)
END SUB

Parameter and execution notes:

  • offset=-2.5 is a signed coordinate offset. Main returns -3. This example calculates an offset; it does not move the character.

CInt — 3

# CInt3
#
# Rounds a number to a whole value, for example a calculated delay or item limit.
#
# Integer, signed 32-bit: halves round away from zero, so 2.5 becomes 3 and -2.5 becomes -3.
# CInt and CLng have the same implementation; CLng does not create a 64-bit value. Use finite
# values whose rounded result is within -2147483648..2147483647. This is not a Boolean result.

SUB Main()
    # ReadDelay receives secondsText="0.35". IsNumeric checks the spelling; CDbl reads seconds.
    # Invalid text, NaN and values outside 0.1..5 seconds return -1. Valid seconds are multiplied by
    # 1000 and rounded: Main returns 350 milliseconds. Use the resulting delay in a later action;
    # the helper itself does not wait.

    RETURN ReadDelay("0.35")
END SUB

SUB ReadDelay(secondsText)
    IF NOT IsNumeric(secondsText) THEN
        RETURN -1
    END IF
    VAR seconds = CDbl(secondsText)
    IF CStr(seconds) = "NaN" OR seconds < 0.1 OR seconds > 5 THEN
        RETURN -1
    END IF
    RETURN CInt(seconds * 1000)
END SUB

Parameter and execution notes:

  • ReadDelay receives secondsText="0.35". IsNumeric checks the spelling; CDbl reads seconds. Invalid text, NaN and values outside 0.1..5 seconds return -1. Valid seconds are multiplied by 1000 and rounded: Main returns 350 milliseconds. Use the resulting delay in a later action; the helper itself does not wait.

Русский · English · Українська · Français · Deutsch · Italiano · Español · 繁體中文 · 日本語 · 한국어

Clone this wiki locally