Skip to content

API CBool en

Codex edited this page Sep 23, 2026 · 1 revision

CBool

ClassicUO / Basic IDE

Home · API · Basic

Converts a numeric value into a condition flag, for example whether a quantity is nonzero.

Exact syntax

CBool(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 1 when the converted number is nonzero; otherwise 0. Negative numbers also give 1. The literals True/False mean 1/0 here, so IF flag, flag = True and flag = 1 can test this result. The text "true" is not the literal True: it converts to 0. NaN/Infinity are nonzero and give 1; this function does not validate numbers.

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

Converts a numeric value into a condition flag, for example whether a quantity is nonzero.

Integer 1 when the converted number is nonzero; otherwise 0. Negative numbers also give 1. The literals True/False mean 1/0 here, so IF flag, flag = True and flag = 1 can test this result. The text "true" is not the literal True: it converts to 0. NaN/Infinity are nonzero and give 1; this function does not validate numbers.

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

Examples

CBool — 1

# CBool1
#
# Converts a numeric value into a condition flag, for example whether a quantity is nonzero.
#
# Integer 1 when the converted number is nonzero; otherwise 0. Negative numbers also give 1. The
# literals True/False mean 1/0 here, so IF flag, flag = True and flag = 1 can test this result.
# The text "true" is not the literal True: it converts to 0. NaN/Infinity are nonzero and give
# 1; this function does not validate numbers.

SUB Main()
    # Integer 1 when the converted number is nonzero; otherwise 0. Negative numbers also give 1. The
    # literals True/False mean 1/0 here, so IF flag, flag = True and flag = 1 can test this result.
    # The text "true" is not the literal True: it converts to 0. NaN/Infinity are nonzero and give
    # 1; this function does not validate numbers.

    RETURN CBool(-5)
END SUB

Parameter and execution notes:

  • Integer 1 when the converted number is nonzero; otherwise 0. Negative numbers also give 1. The literals True/False mean 1/0 here, so IF flag, flag = True and flag = 1 can test this result. The text "true" is not the literal True: it converts to 0. NaN/Infinity are nonzero and give 1; this function does not validate numbers.

CBool — 2

# CBool2
#
# Converts a numeric value into a condition flag, for example whether a quantity is nonzero.
#
# Integer 1 when the converted number is nonzero; otherwise 0. Negative numbers also give 1. The
# literals True/False mean 1/0 here, so IF flag, flag = True and flag = 1 can test this result.
# The text "true" is not the literal True: it converts to 0. NaN/Infinity are nonzero and give
# 1; this function does not validate numbers.

SUB Main()
    # The String "true" is not numeric, so CBool returns 0. For a real flag pass the unquoted
    # literal True, which represents 1, or a numeric comparison.

    RETURN CBool("true")
END SUB

Parameter and execution notes:

  • The String "true" is not numeric, so CBool returns 0. For a real flag pass the unquoted literal True, which represents 1, or a numeric comparison.

CBool — 3

# CBool3
#
# Converts a numeric value into a condition flag, for example whether a quantity is nonzero.
#
# Integer 1 when the converted number is nonzero; otherwise 0. Negative numbers also give 1. The
# literals True/False mean 1/0 here, so IF flag, flag = True and flag = 1 can test this result.
# The text "true" is not the literal True: it converts to 0. NaN/Infinity are nonzero and give
# 1; this function does not validate numbers.

SUB Main()
    # NeedRefill receives current=2 and minimum=5. current < minimum is true; CBool returns 1. Main
    # compares that result with True and returns 1. Replace the sample counts with your own loaded
    # quantities; no inventory is read or moved by this helper.

    IF NeedRefill(2,5) = True THEN
        RETURN 1
    END IF
    RETURN 0
END SUB

SUB NeedRefill(current,minimum)
    RETURN CBool(current < minimum)
END SUB

Parameter and execution notes:

  • NeedRefill receives current=2 and minimum=5. current < minimum is true; CBool returns 1. Main compares that result with True and returns 1. Replace the sample counts with your own loaded quantities; no inventory is read or moved by this helper.

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

Clone this wiki locally