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]