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