{"id":"alexinite/objecat","name":"objecat","scope":"alexinite","platform":"roblox","description":"Mirrored from the Wally registry.","version":"1.1.1","latest":"1.1.1","versions":["1.0.0","1.1.0","1.1.1"],"license":"ISC","licenseRating":"safe","licenseCaveats":[],"licenseVerified":false,"dependencies":{},"integrity":"f97650acffb31980f78431787a0783d320ccaaa4ef7472aa9098c7e9b0cded3c","likes":0,"downloads":0,"install":"forest install alexinite/objecat","url":"https://forest.dev/p/roblox/alexinite/objecat","files":"https://api.forest.dev/ai/package/roblox/alexinite/objecat/files","readme":"<h1 align=\"center\">Objecat</h1>\n<div align=\"center\">\n\tYet Another Way To Create Instances\n</div>\n<div>&nbsp;</div>\n\nObjecat is a very simple library coming with only three functions and one variable. It is used to create Instances in a less verbose way. To put it simply, making an Instance on Roblox and setting its properties is ugly. Objecat makes it less ugly.\n\nObjecat uses standard naming conventions when it comes to properties and methods. Property names and method names are in `camelCase`. This currently does not apply to *after* it is created, only on creation, this may be changed in a future release.\n\n## Installation\nObjecat can be installed in these ways:\n\n- Using [Wally](https://github.com/UpliftGames/wally) (recommended for [Rojo](https://rojo.space/) projects)\n- Using [NPM](https://www.npmjs.com/package/@rbxts/objecat) (recommended for [roblox-ts](https://roblox-ts.com/) projects)\n- Or The [Roblox Model]()\n\n### Installation Using Wally\nTo install using Wally, you just need to add the following to your `wally.toml` file:\n\n```toml\n[dependencies]\nObjecat = \"alexinite/objecat@1.0.0\"\n```\n\nThen run `wally install` in your terminal.\n\n### Installation Using NPM\nIf you're using roblox-ts, this will be the preferred way to download it.\nIt's worth noting that using the roblox-ts package that it is fully type-safe. This currently is not in effect for events, but will be in a future release.\n\n```bash\nnpm install @rbxts/objecat\n```\n\n## Usage\nObjecat has three main exports: `create()`, `event()`, and `children`. These are all documented below.\n\n### `create(className: string, properties?: table): Instance`\n`create<T extends keyof CreatableInstances>(className: T, properties?: ObjecatWritableProperties<Instances[T]>): Instances[T]`\n\n`create()` is the main function of Objecat. Used for creating instances, in general this should be the only top-level function you use from Objecat, the other two are used to define properties and events when creating instances.\n\n```lua\nlocal Objecat = require(path.to.objecat.package)\nlocal create = Objecat.create\n\nlocal part = create(\"Part\", {\n\tanchored = true,\n\tposition = Vector3.new(0, 5, 0),\n\tparent = workspace\n})\n\npart.Anchored = false -- This may be changed in the future to be lowercase\n```\n\n```ts\nimport { create } from \"@rbxts/objecat\";\n\nconst part = create(\"Part\", {\n\tanchored: true,\n\tposition: new Vector3(0, 5, 0),\n\tparent: game.Workspace,\n});\n\npart.Anchored = false;\n```\n\n### `event(str: string): string`\n`event<K extends string>(str: K): \\`__event_${K}__\\``\n\n`event()` just takes a string and returns a string to be used as a symbol for an event. This is used to define events when creating instances. When destroying an Instance created by Objecat, any event will be automatically disconnected for you.\n\n```lua\nlocal event = Objecat.event\n\nlocal part = create(\"Part\", {\n\t[event \"touched\"] = function (otherPart)\n\t\tprint(\"Touched by \" .. otherPart.Name .. \"!\")\n\tend\n})\n\n-- This may be changed in the future to support event()\npart.ChildAdded:Connect(function (child)\n\tprint(\"Child added!\")\nend)\n```\n\n```ts\nimport { create, event } from \"@rbxts/objecat\";\n\nconst part = create(\"Part\", {\n\t[event(\"touched\")] = (otherPart: BasePart) => {\n\t\tprint(`Touched by ${otherPart.Name}!`);\n\t},\n});\n\npart.ChildAdded.Connect((child) => {\n\tprint(\"Child added!\");\n});\n```\n\n### `children: string`\n`children: \"__children__\"`\n\n`children` is a string that just refers to a symbol for adding children to an Instance being created with Objecat. When destroying the parent Instance, all children will be automatically destroyed for you, including their events.\n\nChildren can either be an `Array` (or table) of Instances, or a single Instance.\n\n```lua\nlocal children = Objecat.children\n\nlocal part = create(\"Part\", {\n\t[children] = {\n\t\tcreate(\"PointLight\")\n\t}\n})\n```\n\n```ts\nimport { create, children } from \"@rbxts/objecat\";\n\nconst part = create(\"Part\", {\n\t[children]: [\n\t\tcreate(\"PointLight\")\n\t],\n});\n```\n\n### `clone(instance: Instance, properties?: table): Instance`\n`clone<T extends Instance>(instance: T, properties?: ObjecatWritableProperties<T>): T`\n\n`clone()` is a function that clones an Instance and returns the clone. If `properties.parent` is not set, it will default to the parent of the Instance being cloned. The properties table works the same as the `create()` method. Also, when making a clone it will automatically bind all descendants to a clean-up task.\n\n```lua\nlocal clone = Objecat.clone\n\nlocal part = create(\"Part\", {\n\tanchored = true\n})\n\nlocal newPart = clone(part, {\n\tcolor = Color3.fromRGB(255, 0, 0)\n})\n```\n\n```ts\nimport { create, clone } from \"@rbxts/objecat\";\n\nconst part = create(\"part\", {\n\tanchored: true,\n});\n\nconst newPart = clone(part, {\n\tcolor: Color3.fromRGB(255, 0, 0),\n});\n```\n\n## Current Roadmap\n- [ ] Make the `create()` method behave more like [Elttob](https://github.com/Elttob)'s `New()` method for [Fusion](https://github.com/Elttob/Fusion/).\n- [ ] Maybe add support for after a Instance is created via `create()` to be able to define properties, children, and events as if you were still in the `create()` function.\n- [ ] Add `self` to events created with `event()` so you can access the Instance that the event is attached to.\n- [ ] Somehow make `event()` know what events can and can't be created?","readmeTruncated":false}