NumberValue는 단일 Luau 번호를 저장하는 목적으로 정의된 개체이며, 일반적으로 더블 부동 소수점 숫자 또는 더블 두 배 로 알려져 있습니다.이는 IEEE 754 표현(1개의 부호 비트, 11개의 지수 비트 및 52개의 소수 비트)을 사용하여 64비트(8바이트)에 숫자를 저장합니다.저장할 수 있는 최대 숫자 값은 2^53 또는 9,007,199,254,740,992이며, 최소값은 -9,007,199,254,740,992입니다.최대 15자리의 전체 자릿수를 저장합니다.
모든 "-Value" 개체와 마찬가지로 이 단일 값은 값 속성에 저장됩니다.이것(그리고 이와 유사한 다른 개체)에 대한 변경된 이벤트는 속성이 변경되는 문자열 대신 개체에 저장된 새 값으로 발생합니다.
코드 샘플
This sample demonstrates the subtleties of the Changed event on normal objects and "-Value" objects.
-- Demonstrate the Changed event by creating a Part
local part = Instance.new("Part")
part.Changed:Connect(print)
-- This fires Changed with "Transparency"
part.Transparency = 0.5
-- Similarly, this fires Changed with "Number"
part.Name = "SomePart"
-- Since changing BrickColor will also change other
-- properties at the same time, this line fires Changed
-- with "BrickColor", "Color3" and "Color3uint16".
part.BrickColor = BrickColor.Red()
-- A NumberValue holds a double-precision floating-point number
local vNumber = Instance.new("NumberValue")
vNumber.Changed:Connect(print)
-- This fires Changed with 123.456 (not "Value")
vNumber.Value = 123.456
-- This does not fire Changed
vNumber.Name = "SomeNumber"
-- A StringValue stores one string
local vString = Instance.new("StringValue")
vString.Changed:Connect(print)
-- This fires Changed with "Hello" (not "Value")
vString.Value = "Hello"
요약
이벤트
변경될 때마다 NumberValue.Value가 발사됩니다.
속성
메서드
이벤트
Changed
이 이벤트는 변경될 때마다 NumberValue.Value 속성이 발생합니다.
다른 변경된 이벤트와 마찬가지로 이 이벤트는 숫자 값이 변경될 때와 변경될 수 있는 다양한 값을 추적하는 데 사용할 수 있습니다.
예를 인스턴스, 아이템 ID와 같이 게임 상태와 값을 추적하는 데 사용되는 NumberValues에 의존하는 게임에서도 유용할 수 있습니다.
요구 사항에 가장 적합한 개체 유형에 따라 ObjectValue 및 StringValue와 같은 유사한 개체에 대해 동등한 변경 이벤트가 존재합니다.
매개 변수
변경 후의 값.
코드 샘플
This example prints the NumberValue's new value each time it changes. Here it prints 20.
local numberValue = script.Parent.NumberValue
local function printValue(value)
print(value)
end
numberValue.Changed:Connect(printValue)
numberValue.Value = 20