Is this some obscure kind of fix?

0 favourites
  • 2 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Created a plugin that creates new instances of other plugin using the runtime's documented function createInstance.

    While testing it, found that the "On created" condition was never triggered, to i took a look into the System CreateObject action. What I found was a little disturbing, checked out the Sprite's Spawn action and it did exactly the same disturbing thing:

    It sets some undocumented runtime flag to true before triggering, and returns it to false just after that (See code below). What disturbed me more is that I tried it without the flag and worked without problems. (Maybe it's because I'm not using a container, or because the plugin doesn't have anything about drawing enabled, or some other reason).

    I would like to know what can possibly go wrong if I create some instance and trigger OnCreated without setting that flag to true.

    SysActs.prototype.CreateObject = function (obj, layer, x, y) 
    {
    if (!layer || !obj)
    	return;
    
    var inst = this.runtime.createInstance(obj, layer, x, y);
    
    if (!inst)
    	return;
    
    this.runtime.isInOnDestroy++;
    
    var i, len, s;
    this.runtime.trigger(Object.getPrototypeOf(obj.plugin).cnds.OnCreated, inst);
    
    if (inst.is_contained)
    {
    	for (i = 0, len = inst.siblings.length; i < len; i++)
    	{
    		s = inst.siblings[i];
    		this.runtime.trigger(Object.getPrototypeOf(s.type.plugin).cnds.OnCreated, s);
    	}
    }
    
    this.runtime.isInOnDestroy--;
    
    [...]
    [/code:270emwgh]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're talking about "isInOnDestroy"? I wouldn't worry about it, it's probably some kind of fix related to it's name.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)