From 2d2d41d332143436ed87406111e0f9a63da3ccd3 Mon Sep 17 00:00:00 2001 From: Nikita <61884745+dakln@users.noreply.github.com> Date: Sun, 8 Dec 2024 07:45:28 +0500 Subject: [PATCH] Update README.md --- README.md | 367 +++++++++++++----------------------------------------- 1 file changed, 88 insertions(+), 279 deletions(-) diff --git a/README.md b/README.md index ac458e5..99976ca 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

Lost for easy making Construct 3 Addons.
- v3.0.2 + v3.2.3

@@ -19,8 +19,6 @@ lostinmind. - **[๐Ÿš€ Quickstart](#-quickstart)** - **[๐Ÿ”Œ Creating ***`Plugin`*** addon](#-creating-plugin-addon)** - **[๐ŸŽ›๏ธ Creating ***`Behavior`*** addon](#๏ธ-creating-behavior-addon)** - - --> - **[๐Ÿ—๏ธ Building addon](#๏ธ-building-addon)** - **[๐Ÿงช Testing addon](#-testing-addons-in-developer-mode)** @@ -61,20 +59,17 @@ lost create ``` - **Create a bare-bones project for addon by using one of the following commands:** ```bash -lost create --plugin # Creates a bare-bones project for 'plugin' addon +lost create --plugin # Creates a bare-bones project for 'Plugin' addon ``` ```bash -lost create --behavior # Creates a bare-bones project for 'plugin' addon +lost create --drawing-plugin # Creates a bare-bones project for 'Drawing Plugin' addon ``` - >[!IMPORTANT] Check and install the latest version of Lost CLI! @@ -89,21 +84,25 @@ lost create --plugin # Creates a bare-bones project for 'plugin' addon ### ๐Ÿงฑ File structure ```bash -โ”œโ”€โ”€ Addon/ # Addon folder +โ”œโ”€โ”€ Addon/ # Addon runtime classes folder โ”‚ โ”œโ”€โ”€ Categories/ # Categories folder +โ”‚ โ”œโ”€โ”€ DomSide/ # Addon DOM side scripts folder โ”‚ โ”œโ”€โ”€ Files/ # Addon files folder โ”‚ โ”œโ”€โ”€ Scripts/ # Addon scripts folder โ”‚ โ”œโ”€โ”€ Modules/ # Addon modules folder โ”‚ โ”œโ”€โ”€ Types/ # Addon scripts folder โ”‚ โ””โ”€โ”€ global.d.ts # Declaration file for your purposes โ”‚ โ”œโ”€โ”€ icon.svg # Your .svg OR .png addon icon -โ”‚ โ”œโ”€โ”€ Instance.ts # Addon Instance class -โ”‚ โ”œโ”€โ”€ Plugin.ts # Addon Plugin class -โ”‚ โ””โ”€โ”€ Type.ts # Addon Type class +โ”‚ โ”œโ”€โ”€ Instance.ts # Addon runtime Instance class +โ”‚ โ”œโ”€โ”€ Plugin.ts # Addon runtime Plugin class +โ”‚ โ””โ”€โ”€ Type.ts # Addon runtime Type class โ”œโ”€โ”€ Builds/ # Builds folder โ”‚ โ”œโ”€โ”€ Source/ # Final Construct 3 addon folder โ”‚ โ””โ”€โ”€ ... โ”‚ โ””โ”€โ”€ AddonId_Version.c3addon # Final .c3addon file +โ”œโ”€โ”€ Editor/ # Builds folder +โ”‚ โ”œโ”€โ”€ Instance.ts # Editor Instance class +โ”‚ โ””โ”€โ”€ Type.ts # Editor Type class โ”œโ”€โ”€ deno.json # deno.json file for Deno enviroment โ”œโ”€โ”€ addon.ts # Main addon file โ”œโ”€โ”€ lost.config.ts # Addon config file @@ -113,13 +112,17 @@ lost create --plugin # Creates a bare-bones project for 'plugin' addon Let's setup _`lost.config.ts`_ config file at first. ```typescript -import type { LostConfig } from "jsr:@lost-c3/lib@"; +import { defineConfig } from "jsr:@lost-c3/lib"; -const config: LostConfig = { +export default defineConfig<'plugin'>({ /** * Set addon type */ type: 'plugin', + /** + * Set plugin type + */ + pluginType: 'object' | 'world', /** * Set a boolean of whether the addon is deprecated or not. */ @@ -158,59 +161,63 @@ const config: LostConfig = { helpUrl: { EN: 'https://myaddon.com/help/en' } -} - -export default config; +}) ``` ### โš™๏ธ Addon setup Let's setup _`addon.ts`_ file at second. ```typescript -import { Plugin, Property } from 'jsr:@lost-c3/lib@3.0.0'; +import { defineAddon, Plugin, Property } from 'jsr:@lost-c3/lib'; +import type { EditorInstance } from "@Editor/Instance.ts"; +import type { EditorType } from "@Editor/Type.ts"; import config from "./lost.config.ts"; -const Addon = new Plugin(config) - -Addon - .addFilesToOutput() - - .setRuntimeScripts() - - .addRemoteScripts('https://cdn/index.js') - - /** @Properties */ - .addPluginProperty('integer', 'Integer', { type: Property.Integer }) - .addPluginProperty('float', 'Float', { type: Property.Float }) - .addPluginProperty('percent', 'Percent', { type: Property.Percent }) - .addPluginProperty('text', 'Text', { type: Property.Text }) - .addPluginProperty('longText', 'Long Text', { type: Property.LongText }) - .addPluginProperty('check', 'Check', { type: Property.Checkbox }) - .addPluginProperty('font', 'Font', { type: Property.Font }) - .addPluginProperty('combo', 'Combo', { - type: Property.Combo, - items: [['item1', 'item2']] - }) - .addPluginProperty('color', 'Color', { type: Property.Color, initialValue: [255, 210, 155] }) - .createGroup('group', 'Awesome Group') - .addPluginProperty('info', 'Info', { type: Property.Info, info: 'Lost' }) - .addPluginProperty('link', 'Link', { - type: Property.Link, - callbackType: 'for-each-instance', - callback: (inst) => { - console.log('Link property for each instance'); - } +export default defineAddon( + new Plugin(config) + .addFilesToOutput() + + .setRuntimeScripts() + + .addRemoteScripts('https://cdn/index.js') + + /** @Properties */ + .addProperty('integer', 'Integer', { type: Property.Integer }) + .addProperty('float', 'Float', { type: Property.Float }) + .addProperty('percent', 'Percent', { type: Property.Percent }) + .addProperty('text', 'Text', { type: Property.Text }) + .addProperty('longText', 'Long Text', { type: Property.LongText }) + .addProperty('check', 'Check', { type: Property.Checkbox }) + .addProperty('font', 'Font', { type: Property.Font }) + .addProperty('combo', 'Combo', { + type: Property.Combo, + items: [['item1', 'item2']] }) - .addPluginProperty('link2', 'Link', { - type: Property.Link, - callbackType: 'once-for-type', - callback: (type) => { - console.log('Link property once for type'); - } - }) -; - -export default Addon; + .addProperty('color', 'Color', { type: Property.Color, initialValue: [255, 210, 155] }) + .createGroup('group', 'Awesome Group') + .addProperty('info', 'Info', { + type: Property.Info, + callback: (inst) => { + return ''; + } + }) + .addProperty('link', 'Link', { + type: Property.Link, + linkText: 'Do ...', + callbackType: 'for-each-instance', + callback: (inst) => { + console.log('Link property for each instance'); + } + }) + .addProperty('link2', 'Link', { + type: Property.Link, + linkText: 'Do ...', + callbackType: 'once-for-type', + callback: (type) => { + console.log('Link property once for type'); + } + }) +) ``` ### ๐Ÿ“ Creating category @@ -224,7 +231,7 @@ import { Category, Action, Condition, Expression, addParam } from "jsr:@lost-c3/ import type { Instance } from "../Instance.ts"; @Category('myCategory', 'Category Name', { isDeprecated: false, inDevelopment: false }) -export default class MyCategory { +export default class { /** @Actions */ /** @Conditions */ @@ -313,7 +320,7 @@ import { Category, Action, Condition, Expression } from 'jsr:@lost-c3/lib'; import type { Instance } from '../Instance.ts'; @Category('categoryId', 'Category Name') -export default class MyCategory { +export default class { @Condition( `onEvent`, `On event`, @@ -369,7 +376,7 @@ import { Category, Action, Condition, Expression } from 'jsr:@lost-c3/lib'; import type { Instance } from '../Instance.ts'; @Category('categoryId', 'Category Name') -export default class MyCategory { +export default class { @Expression( `getValue`, `GetValue`, @@ -431,7 +438,7 @@ import { bold } from 'jsr:@lost-c3/lib/misc'; import type { Instance } from '../Instance.ts'; @Category('categoryId', 'Category Name') -export default class MyCategory { +export default class { @Action({ `doActionWithParams`, `Do action`, @@ -468,7 +475,7 @@ import { Action, Category, Condition, Expression } from 'jsr:@lost-c3/lib'; import type { Instance } from '../Instance.ts'; @Category('categoryId', 'Category Name') -export default class MyCategory { +export default class { @Action(`doAction`, `Do action`, `Do action`, { /** * Default is False. Set to true to deprecate the ACE. @@ -489,8 +496,6 @@ Example of using Instance properties and functions inside any category entity _Instance.ts_ ```typescript -const C3 = globalThis.C3; - class LostInstance extends globalThis.ISDKInstanceBase { readonly value: string = 'My property value'; /** @@ -522,7 +527,6 @@ class LostInstance extends globalThis.ISDKInstanceBase { } } -C3.Plugins[Lost.addonId].Instance = LostInstance; export type { LostInstance as Instance }; ``` @@ -536,7 +540,7 @@ import { Action, Category, Condition, Expression } from 'jsr:@lost-c3/lib'; import type { Instance } from '../Instance.ts'; @Category('categoryId', 'Category Name') -export default class MyCategory { +export default class { @Expression(`getValue`, `GetValue`) /** * Set the first argument of your method to: this: Instance @@ -570,16 +574,15 @@ To use any script you should copy OR create _**script.js**_ OR _**script.ts**_ f *Example* ```typescript -import { Plugin, Property } from 'jsr:@lost-c3/lib@3.0.0'; +import { Plugin, Property } from 'jsr:@lost-c3/lib'; +import type { EditorInstance } from "@Editor/Instance.ts"; +import type { EditorType } from "@Editor/Type.ts"; import config from "./lost.config.ts"; -const Addon = new Plugin(config) - -Addon - .setRuntimeScripts('runtime-index.js') -; - -export default Addon; +export default defineAddon( + new Plugin(config) + .setRuntimeScripts('myscript1.ts', 'main/myscript.ts') +) ``` ### ๐Ÿ“„ Using Files @@ -594,16 +597,15 @@ To use any file you should copy OR create _**file.***_ file at path: *Example* ```typescript -import { Plugin, Property } from 'jsr:@lost-c3/lib@3.0.0'; +import { Plugin, Property } from 'jsr:@lost-c3/lib'; +import type { EditorInstance } from "@Editor/Instance.ts"; +import type { EditorType } from "@Editor/Type.ts"; import config from "./lost.config.ts"; -const Addon = new Plugin(config) - -Addon - .addFilesToOutput('myfile.wasm') -; - -export default Addon; +export default defineAddon( + new Plugin(config) + .addFilesToOutput('myfile.wasm') +) ``` ### ๐Ÿ“ฆ Using Modules @@ -617,8 +619,6 @@ To use any module you should copy OR create _**mymodule.js**_ file at path: ```typescript import * as MyModule from './Modules/mymodule.ts'; -const C3 = globalThis.C3; - class LostInstance extends globalThis.ISDKInstanceBase { readonly PluginConditions = C3.Plugins[Lost.addonId].Cnds; @@ -640,7 +640,6 @@ class LostInstance extends globalThis.ISDKInstanceBase { }; -C3.Plugins[Lost.addonId].Instance = LostInstance; export type { LostInstance as Instance }; ``` @@ -675,7 +674,7 @@ import { Action, Category } from 'jsr:@lost-c3/lib'; import type { Instance } from '../Instance.ts'; @Category('categoryId', 'Category Name') -export default class MyCategory { +export default class { @Action( `doAction`, `${bold('Action name')}`, @@ -686,196 +685,6 @@ export default class MyCategory { } ``` - - - - - - ## ๐Ÿ—๏ธ Building addon To build addon into **`.c3addon`** file you can use one of the following