rhg1968's Recent Forum Activity

  • Tom

    That did it, Thank you !!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Thank you for getting back to me. You were right, as I looked at what my plugin was actually doing I really didn't need to call those event sheet functions. I was able to make it work correctly without those calls and now my plugin is all set for v2.

  • I am porting a global plugin I made awhile ago over to v2.

    In my original plugin the calls to GetCurrentEventStackFrame and GetCurrentEvent worked fine.

    Once I upgraded to V2 I get this.runtime.GetCurrentEventStackFrame is not a function

    Any guidance would be appreciated

    Here is the original condition:

    "use strict";
    
    {
    	self.C3.Plugins.RGBZ_PubSub.Cnds =
    	{
    		SubscribeToEvent(name)
    		{
    			console.info(`Subscribe called ${name}`);
    
    			const current_frame = this._runtime.GetCurrentEventStackFrame();
    			const current_event = this._runtime.GetCurrentEvent();
    	
    			const eventId = current_event._sid.toString() + '-' + current_frame._cndIndex.toString();
    
    			if (this.EventPublished && this.EventPublished.Name==name.toLowerCase() 
    					&& this.EventPublished.HandledBy.find(x=>x==eventId)==null) {
    				this.EventPublished.HandledBy.push(eventId);
    
    				return true;
    			}
    			else {
    				return false;
    			}
    		}
    	};
    }

    Here is the new V2 version

    "use strict";
    
    const C3 = globalThis.C3;
    
    C3.Plugins.RGBZ_PubSub.Cnds =
    {
    	SubscribeToEvent(name)
    	{
    		console.info(`Subscribe called ${name}`);
    
    		const current_frame = this.runtime.GetCurrentEventStackFrame();
    		const current_event = this.runtime.GetCurrentEvent();
    
    		const eventId = current_event._sid.toString() + '-' + current_frame._cndIndex.toString();
    
    		if (this.EventPublished && this.EventPublished.Name==name.toLowerCase() 
    				&& this.EventPublished.HandledBy.find(x=>x==eventId)==null) {
    			this.EventPublished.HandledBy.push(eventId);
    
    			return true;
    		}
    		else {
    			return false;
    		}
    	}
    };
    
  • Your script block is at the same level as the on start layout. So it's not part of that event. It gets called every ticket of the game.

    You need to either add it directly to on start layout or to a new sub event of the on start for it to only run once/

    If you want to call it from the event sheet as a function you should move it to a separate js file and import it into the events js file so it's available to call in the event sheet

  • Thank you for your input. Worst case I can disable the extension when creating a new project. Once the project is created there aren't any issues.

  • I tried it in edge and it worked. So I disabled all extensions and it worked. So I started turning extensions back on. It appears it is happening with the last pass extension. Last Pass is a password management app. So not the greatest situation because it is one that I definitely like to use and it causes the issue.

rhg1968's avatar

rhg1968

Early Adopter

Member since 6 Jun, 2014

Twitter
rhg1968 has 9 followers

Trophy Case

  • 10-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

18/44
How to earn trophies

Blogs