Skip to main content
实例和属性的反射助手。

可用函数

gethiddenproperty

通过 reflection metadata 读取 Roblox property,包括 non-scriptable properties。第一个参数必须是 Instance object,第二个参数必须是 string property name。instance reference 必须有效。如果 Roblox property metadata 中缺少 property descriptor,function 只返回 nil。如果 descriptor 存在但无法解析为 property entry,会抛出 “Not a property”。对于 reflection types Bool、Int、Float、Double、String、SystemAddress、SharedString 和 Vector3,function 会调用 getter,并返回 value 加上等于 !IsScriptable() 的 boolean。SystemAddress 返回 RemoteId.PeerId 作为 integer。SharedString 返回 Content 作为 string。Vector3 从 instance primitive Size offset 读取,如果 touch data 缺失则抛出 “can’t get value”。其他 property types 会在临时将 property scriptable flag 设置为 true 后通过 normal Lua field access 读取;BinaryString 在该读取期间会临时当作 String 处理。original scriptable flag 和 BinaryString type 会在 return 前恢复。

isscriptable

检查 Instance 上 Roblox property 的 scriptable flag。function 会先返回同一 instance reference 和 property name 的 cached scriptable value。如果 cache miss,则通过 Roblox property metadata 和 Instance class descriptor 解析 property name。如果 descriptor 不存在,或解析到的 field 缺失,或不是 property entry,function 返回 nil。找到 property entry 时,function 读取 scriptable state,把该值保存到该 instance 和 property 的 scriptable override cache,然后返回 boolean。function 不会更改 scriptable flag。

sethiddenproperty

Sets a Roblox property with reflection metadata. The first argument must be Instance object, the second argument must be a string property name, and the third argument must be present. The instance reference must be valid. If the property descriptor is missing from Roblox property metadata, the function returns nil. If the descriptor exists but does not resolve to a property entry, it raises “Not a property”. Bool values use luaL_checkboolean. Int and SystemAddress values use integer type checking, with SystemAddress writing RemoteId.PeerId. Float and Double values use number type checking. String, SharedString, and BinaryString values use string type checking before calling the setter. For other property types, the function temporarily calls setscriptable(instance, property, true), assigns instance[property] = value with normal Lua field assignment, then restores the original scriptable state with setscriptable(instance, property, isScriptable). On successful writes, the return value is a boolean equal to !IsScriptable() from before the write.

setscriptable

将 Roblox property 的 scriptable override 存入 scriptable override cache,并返回 previous scriptable state。第一个参数必须是 Instance object,第二个参数必须是 string property name,第三个参数必须是 boolean。如果同一 instance reference 和 property name 已有 cache entry,则替换 cached scriptable value,并返回旧的 cached value。cache miss 时,通过 Roblox property metadata 和 Instance class descriptor 解析 property name。如果 descriptor 不存在,或解析到的 field 缺失,或不是 property entry,function 返回 nil。找到 property entry 时,function 读取 scriptable state,把请求的 boolean 和 property reference 存入 scriptable override cache,然后返回 previous scriptable state value。GameIndexHook 和 GameNewIndexHook 稍后会使用这个 cache,在一次 indexed read 或 write 期间临时设置 property field scriptable flag,然后恢复 previous field flag。