Add launchable

This commit is contained in:
usernames122
2025-10-23 20:58:19 +02:00
parent 300bb16e5e
commit d9d5460856
27 changed files with 1743 additions and 85 deletions

View File

@@ -5,7 +5,7 @@ let instanceCounter = 0;
export class Instance {
constructor(className = "Instance") {
this.ClassName = className;
this.Name = `${className}${instanceCounter++}`;
this.Name = `${className}`;
this.Parent = null;
this.Children = [];
this.InstanceId = guidGenerator(); // Unique identifier, used for replication
@@ -120,4 +120,21 @@ export class Instance {
console.warn("Destroy: No DataModel found in ancestry. Are you destroying an unparented instance?");
}
} // Garbage collected after this
LuaBridge(exclude, visited = new Set()) { // Convert to a plain object for LuaBridge. Should be overridden in subclasses to add properties.
if (visited.has(this.InstanceId)) {
// Already visited, avoid circular reference
return null;
}
visited.add(this.InstanceId);
const obj = {
ClassName: this.ClassName,
Name: this.Name,
InstanceId: this.InstanceId,
Properties: {},
Children: this.Children.filter(c => c !== exclude).map(c => c.LuaBridge(this, visited)).filter(Boolean),
Parent: this.Parent && this.Parent !== exclude ? this.Parent.LuaBridge(this, visited) : null // Avoid circular reference by excluding self
};
return obj;
}
}