mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 04:50:36 +00:00
Implement GetDebugId instance method
This commit is contained in:
parent
56949aad09
commit
1c814285c6
5 changed files with 22 additions and 0 deletions
|
@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- Added the `GetDebugId` instance method to the `roblox` built-in. This will return the internal id used by the instance, and as the name implies, it should be primarily used for _debugging_ purposes and cases where you need a globally unique identifier for an instance. It is guaranteed to be a 32-digit hexadecimal string.
|
||||
|
||||
## `0.7.9` - October 21st, 2023
|
||||
|
||||
### Added
|
||||
|
|
|
@ -49,6 +49,9 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(m: &mut M) {
|
|||
ensure_not_destroyed(this)?;
|
||||
this.get_full_name().into_lua(lua)
|
||||
});
|
||||
m.add_method("GetDebugId", |lua, this, ()| {
|
||||
this.dom_ref.to_string().into_lua(lua)
|
||||
});
|
||||
m.add_method("FindFirstAncestor", |lua, this, name: String| {
|
||||
ensure_not_destroyed(this)?;
|
||||
this.find_ancestor(|child| child.name == name).into_lua(lua)
|
||||
|
|
|
@ -178,6 +178,7 @@ create_tests! {
|
|||
roblox_instance_methods_find_first_child_of_class: "roblox/instance/methods/FindFirstChildOfClass",
|
||||
roblox_instance_methods_find_first_child_which_is_a: "roblox/instance/methods/FindFirstChildWhichIsA",
|
||||
roblox_instance_methods_get_children: "roblox/instance/methods/GetChildren",
|
||||
roblox_instance_methods_get_debug_id: "roblox/instance/methods/GetDebugId",
|
||||
roblox_instance_methods_get_descendants: "roblox/instance/methods/GetDescendants",
|
||||
roblox_instance_methods_get_full_name: "roblox/instance/methods/GetFullName",
|
||||
roblox_instance_methods_is_a: "roblox/instance/methods/IsA",
|
||||
|
|
11
tests/roblox/instance/methods/GetDebugId.luau
Normal file
11
tests/roblox/instance/methods/GetDebugId.luau
Normal file
|
@ -0,0 +1,11 @@
|
|||
local roblox = require("@lune/roblox")
|
||||
|
||||
local part = roblox.Instance.new("Part")
|
||||
|
||||
local id = part:GetDebugId()
|
||||
assert(type(id) == "string", "GetDebugId should return a string")
|
||||
assert(#id == 32, "GetDebugId should return a string with length 32")
|
||||
assert(
|
||||
string.match(id, "^[0-9A-Fa-f]+$"),
|
||||
"GetDebugId should return a string with only hexadecimal characters"
|
||||
)
|
|
@ -145,6 +145,7 @@ type InstanceMetatable = {
|
|||
ClearAllChildren: (self: Instance) -> (),
|
||||
|
||||
GetChildren: (self: Instance) -> { Instance },
|
||||
GetDebugId: (self: Instance) -> string,
|
||||
GetDescendants: (self: Instance) -> { Instance },
|
||||
GetFullName: (self: Instance) -> string,
|
||||
|
||||
|
|
Loading…
Reference in a new issue