0 Favourites

Is this some obscure kind of fix?

  • 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]
  • Construct 3

    Buy Construct 3

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

    Buy 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)
Similar Topics Posts Views Last Post
Unread hot topic
175 32,641
clifton11221's avatar
clifton11221
Unread hot topic
107 17,832
ZeroBiss's avatar
ZeroBiss
Unread hot topic
98 7,598
norum82's avatar
norum82