-
Notifications
You must be signed in to change notification settings - Fork 0
API CInt en
ClassicUO / Basic IDE
Rounds a number to a whole value, for example a calculated delay or item limit.
CInt(value:Any) -> Integer
-
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.
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.
- 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.
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.
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.
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.
# CInt — 1
#
# 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 SUBParameter 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
#
# 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 SUBParameter 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
#
# 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 SUBParameter 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 · 繁體中文 · 日本語 · 한국어
ClassicUO
Bad Newbie & Basic IDE
Найти в справочнике
Клиент и скрипты
Каталоги значений
Разработка и помощь