Byloth's Recent Forum Activity

  • Oh, awesome!

    I lost the last commit from 3 weeks ago on https://github.com/Scirra/Construct-Addon-SDK/!

    That makes a lot more sense.

    Thanks!

    ---

    Just a personal thought, about this...

    Allowing developers to define their own c3runtime/main.js file is -indeed- a great thing.

    Just to try (let's not argue about if it was theoretically correct or not) I had Vite.js compile a single c3runtime/main.js file with all my plugin logic inside it.

    After all, my c3runtime/main.ts included all the different project files, so Vite.js did what it was asked to do: it included everything in a single file.

    This led me to have a single file inside my c3runtime directory.

    I edited -of course- both the addon.json and plugin.ts files accordingly, making sure it was the only runtime file listed inside the "file-list" array and configured it as the main script with the SetRuntimeModuleMainScript function.

    It just didn't work.

    It seems to still be looking for all the plugin-specific files (c3runtime/plugin.js, c3runtime/types.js, etc...), which leads to this error when the project is run.

    Now... I'm pretty sure I missed something, but...

    What's the point of allowing developers to define their own c3runtime/main.js if other different files are automatically searched anyway?

    ---

    But in the end, if you're also here looking for the solution, know that I didn't used this new c3runtime/main.js thing.

    What I was missing was simply this line inside my plugin.ts file:

    this._info.AddC3RuntimeScript("c3runtime/vendors.js");
    

    Add this and you'll be ok!

  • Hi.

    I'm developing a new Construct Plugin with SDK 2.

    For this particular plugin, I created a repository based on Vite.js as bundler to easily build a Construct Plugin using TypeScript and other useful stuff.

    (If it can be interesting, I will create a template repository on GitHub for other people to use as well.)

    ---

    Now... I'm facing this issue with vendor dependencies that I need to be bundled with the plugin itself.

    Note that these dependencies aren't added to the window object like old-usual global properties, but I'm using ES modules so they will be imported where they are needed.

    For this reason, I need a separated file, a new one, different from the usual files available for plugins.

    In my project, I make it so that it is compiled as a generic c3runtime/vendors.js file.

    BUT...

    This seems to be the actual problem.

    Plugins aren't meant to accept extra files, other than those defined.

    It doesn't seem to matter whether the file is mentioned inside the addon.json file or not...

    In my case:

    {
     /* ... */
    
     "file-list": [
     "c3runtime/plugin.js",
     "c3runtime/type.js",
     "c3runtime/instance.js",
     "c3runtime/conditions.js",
     "c3runtime/actions.js",
     "c3runtime/expressions.js",
     "c3runtime/vendors.js",
     "lang/en-US.json",
     "aces.json",
     "addon.json",
     "icon.svg",
     "index.js"
     ]
    }
    

    This leads to an eerror when running the project:

    [C3 runtime] Failed to load all engine scripts in worker: TypeError: Failed to fetch dynamically imported module: https://preview.construct.net/scripts/c3main.js
    

    Leaving aside the error message itself which, to be honest, doesn't say anything...

    To find out what the actual problem was, I had to to read the Network tab where I got a 404 over this file: https://preview.construct.net/scripts/plugins/Test_MyPlugin/c3runtime/vendors.js.

    How can I fix this?

    Can I hope for a fix for the Construct Plugin SDK (that would improve DX a lot) or do I need to do something different?

    Thanks.

  • This is now supported in r401 with the new method createLoopingConditionContext(). You can use it like this (sample code for a 'TestLoop' condition that repeats a number of times):

    > TestLoop(count)
    {
    	const loopCtx = this.runtime.sdk.createLoopingConditionContext();
    
    	for (let i = 0; i < count; ++i)
    	{
    		loopCtx.retrigger();
    
    		if (loopCtx.isStopped)
    			break;
    	}
    
    	loopCtx.release();
    }
    

    Hi, Ashley!

    The property sdk appears to be undefined on TypeScript types.

    createLoopingConditionContext is -indeed- defined on a ISDKUtils type which is never referenced or used in any other type-def file.

    FYI, I just generated the type-def files using version r403.

    Is this a bug?

    Thank you.

  • Mmmh... Ok, strange!

    I started by cloning this repository.

    Then, I enabled "Developer Mode" in Construct and selected "Set up TypeScript for Addon". After a while, a popup informed me that exactly 96 files had been generated inside my project directory.

    I installed TypeScript with NPM and tried to compile the project.

    These are the errors I've got:

    > Dinostruct Pluginxys@1.0.0 typecheck /home/matteo/projects/dinostruct-plugin
    

    tsc

    instance.ts(2,24): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    instance.ts(8,23): error TS2503: Cannot find namespace 'SDK'.

    instance.ts(8,44): error TS2503: Cannot find namespace 'SDK'.

    instance.ts(21,39): error TS2304: Cannot find name 'EditorPropertyValueType'.

    plugin.ts(2,24): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    plugin.ts(25,33): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    plugin.ts(26,40): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    plugin.ts(29,36): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    type.ts(2,24): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    type.ts(8,25): error TS2503: Cannot find namespace 'SDK'.

    type.ts(8,55): error TS2503: Cannot find namespace 'SDK'.

     ELIFECYCLE  Command failed with exit code 2.

    ---

    I read the type definition files and I wasn't able to find a SDK namespace.

    I discovered -in fact- a C3 namespace (defined in the ts-defs/runtime/AddonSDK.d.ts file), used within some files like c3runtime/actions.ts, c3runtime/conditions.ts, c3runtime/expressions.ts and so on... But no SDK.

    I also searched for some of the classes mentioned and used within the 3 files that throw errors like SDK.IInstanceBase or SDK.IPluginBase but I wasn't able to find those either.

    Instead, I discovered some similar classes: ISDKInstanceBase & ISDKPluginBase; but then I realized that they are already used in the c3runtime/instance.ts and c3runtime/plugin.ts files.

    I also couldn't find any similar reference to EditorPropertyValueType used in the instance.ts file on line 21.

    ---

    Of course I know I'm doing something wrong but I can't figure out what is it.

    What's the problem? What am I doing wrong?

    Thanks.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, everybody.

    I'm new with Construct 3.

    I'm trying to develop a plugin using TypeScript.

    I've already added TypeScript support following this guide but something seems to be missing.

    Within the 3 files `instance.ts`, `plugin.ts` and `type.ts` the `globalThis.SDK` object is referenced quite a lot but is not defined anywhere.

    Am I doing something wrong?

    How can I solve this issue?

    Thanks.

Byloth's avatar

Byloth

Member since 15 Feb, 2023

None one is following Byloth yet!

Trophy Case

  • 1-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

3/44
How to earn trophies