rhg1968's Recent Forum Activity

  • Interesting side note on Import Maps ASHLEY.

    It is working now as expected on one machine. If I run the same project on 2 other PCs I get 404 errors trying to load.

    I noticed that the <script type="importmap" /> is there everything works correctly.

    On the other two machines that script tag is missing on preview and the json importmap is not included so then it can't resolve the module names.

    So I am not sure why it's included in one preview on one machine but not on my other machines.

    I would definitely appreciate any thoughts you have.

    Thank you

  • Thank you, for some reason I thought it was relative from the file that was importing a module. That makes things a lot easier :)

  • I guess my question revolves around files being in different sub-folders referring to a common import. The relative path to that shared file would be different from each file in a different sub-folder. So wouldn't that make it impossible for the same import to be utilized ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I wanted to utilize a import map so that I only needed to change things in one place if the location of files in project needed to be changed. However, I ran into an issue that makes me think this will not work well with a Construct 3 project.

    The problem is that the simplest way to make the import path work in all cases is to base it off the the root of the web app. A issue arises when you export the project lets say for windows. So here is what a possible import map file looks like and a directory structure I am using.

    { "imports" : { "ecs_manager": "/ECS/ECSManager.js", "player": "/ECS/Player.js", "enemy": "/ECS/Enemy.js", "text": "/ECS/Text.js", "move_system": "/ECS/MoveSystem.js", "collision_system": "/ECS/CollisionSystem.js", "component": "/ECS/Component.js", "move_component": "/ECS/MoveComponent.js", "coll_polygon_component": "/ECS/CollPolygonComponent.js", "entity": "/ECS/Entity.js", "utilities": "/Utilities/Utilities.js", "vector": "/Utilities/Vector.js", "enemy_component": "/ECS/EnemyComponent.js", "system": "/ECS/System.js" } }

    In preview mode the /ECS directory is off of the root so I can use the key in an import statement in main.js and in a file that's in ECS folder that reference the same import because it's based off the root.

    When I export for windows there are additional directories before the ECS now so the path from root is different.

    This makes you revert back to relative paths, but now you can't use the same import map key because the path to the file is different from different directories.

    Just wondering if anyone else has a solution to this or I may just not use import maps at all.

    Thanks

    Tagged:

  • In your subclass it doesn't show that you are exporting the class.

  • Tom

    That did it, Thank you !!!

  • Tom

    I just tried again and I am still getting the error

  • I am getting ready to upload a new version of my plugin and I get an error message that archive can't contain .svg files anymore. That is icon file for the Plugin. If I download the SDK templates they have an svg file and the documentation indicates that the icon.svg file is what it is supposed to be. Just wanted to see if something has changed that I am not aware of.

  • I am on version 407.2

    I created a simple project and imported a simple class without issue.

    I was testing import maps and it throws an error that it can't resolve the import name and it needs to be relative or direct path with a . or /

    I did make the import map json of the type import map.

    This works correctly

    import {Item} from "/Items/Item.js";
    // Import any other script files here, e.g.:
    // import * as myModule from "./mymodule.js";
    
    runOnStartup(async runtime =>
    {
    	// Code to run on the loading screen.
    	// Note layouts, objects etc. are not yet available.
    	
    	runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
    });
    
    async function OnBeforeProjectStart(runtime)
    {
    	// Code to run just before 'On start of layout' on
    	// the first layout. Loading has finished and initial
    	// instances are created and available to use here.
    	
    	const test = new Item(123);
    	
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function Tick(runtime)
    {
    	// Code to run every tick
    }
    

    I then created a json file and set it's type to import map

    Changed my main.js file like so

    import {Item} from "myItem";
    // Import any other script files here, e.g.:
    // import * as myModule from "./mymodule.js";
    
    runOnStartup(async runtime =>
    {
    	// Code to run on the loading screen.
    	// Note layouts, objects etc. are not yet available.
    	
    	runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
    });
    
    async function OnBeforeProjectStart(runtime)
    {
    	// Code to run just before 'On start of layout' on
    	// the first layout. Loading has finished and initial
    	// instances are created and available to use here.
    	
    	const test = new Item(123);
    	
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function Tick(runtime)
    {
    	// Code to run every tick
    }
    

    I then get the following error

    [C3 preview] Browser opened wrong size popup: wanted 854 x 480, got 854 x 479; resizing to compensate
    local.html:1 Uncaught TypeError: Failed to resolve module specifier "myItem". Relative references must start with either "/", "./", or "../".Understand this error
    domSide.js:37 Error loading project main script: Error: main script did not run to completion
     at RuntimeInterface._InitDOM (domSide.js:37:143)
     at async RuntimeInterface._Init (domSide.js:29:261)
    _InitDOM @ domSide.js:37Understand this error
    runtime.js:26 
  • I have an addon in the store that does exactly what has been mentioned.

    construct.net/en/game-assets/addons/publish-subscribe-events-2497

  • The only thing I noticed was that you are storing your calculated result in a string and then the return type of the function is a number, which may convert it a 0.

  • I agree this feature would be game changing. GDevelop has this ability and it really is nice to be able to create behaviors in the editor using events or JavaScript snippets.

rhg1968's avatar

rhg1968

Early Adopter

Member since 6 Jun, 2014

Twitter
rhg1968 has 9 followers

Trophy Case

  • 11-Year Club
  • Entrepreneur Sold something in the asset store
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

19/44
How to earn trophies

Blogs