When to modify "trig.solModifiers"?

For developers using the Construct 2 Javascript SDK

Post » Wed Mar 28, 2012 4:48 pm

Hi,

I try to make an action which has an object-type parameter. My goal is to pass the uid of selected instance (sol.select = false) from sol.

Fist, I try to use object-type parameter. The sol of this object will be push by "trig.solModifiers" (eveng.js, line 1626). So that I can not pick the target instance, since sol is in a new sol-stack.

Second, I try to use number-type parameter. Then put expression object.UID in event sheet.
In this case, "trig.solModifiers" does not contain this object, so that the sol will not be push, the sol-stack will not change. I can pick target instance from sol.


one is picked by object-type parameter, the other is picked by expression. Why "trig.solModifiers" will be different?rexrainbow2012-03-28 16:51:04
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Wed Mar 28, 2012 6:14 pm

If you modify the picked objects, it must be in the solModifiers array so the SOL stack correctly pushes and pops. Any object in an object parameter is automatically added to solModifiers by the event system so you can safely pick or unpick instances from an object parameter.

TBH the event system is not yet designed to allow triggers to access the calling event's SOL (the function features when we add them should allow that). The UID thing is a hack and will not work if you add a condition affecting that object, because then the trigger's solModifiers will also contain that type and you'll still get a clean SOL.

Another hack which might work is still use an object parameter, but try looking one level up the SOL stack. Not sure that will work 100% though.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Thu Mar 29, 2012 12:54 am

[QUOTE=Ashley]Any object in an object parameter is automatically added to solModifiers by the event system so you can safely pick or unpick instances from an object parameter.[/QUOTE]

Yes, that is true.


[QUOTE=Ashley]If you modify the picked objects, it must be in the solModifiers array so the SOL stack correctly pushes and pops.[/QUOTE]
[QUOTE=Ashley]the trigger's solModifiers will also contain that type and you'll still get a clean SOL.[/QUOTE]


Not all modified objects will be in "solModifiers" array.
I found the sol-stack does not always push a clean one by observed the sol stack in my second method. That's why I can pick uid in expression.




[QUOTE=Ashley]the event system is not yet designed to allow triggers to access the calling event's SOL[/QUOTE]

Oh no~ I'm sure the sol-stack does not change when I test function plugin a few months before.



[QUOTE=Ashley]Another hack which might work is still use an object parameter, but try looking one level up the SOL stack. Not sure that will work 100% though.[/QUOTE]

Auto-clean sol is a good design to make sure the sol is the same (clean).
Would you mind to add a function to tell the engine to keep sol-stack without push a clean one, so that plugin can control the sol manually.



Thanks for your reply.rexrainbow2012-03-29 12:30:46
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Thu Mar 29, 2012 12:50 pm

I move instances selecting from action to triggered condition. It works, I can get instances correctly in action under triggered condition.rexrainbow2012-03-29 12:56:20
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Fri Mar 30, 2012 3:06 pm

rex, your SysExt will be perfect if you combined it with instance Grouping.. Enable Disable Behavior by Group or instance..if it is possible..

it usefull for Grouping Object like NPC or Monster
Ally Or Enemy..

Pick instance by property comparing should be enabled in event too i think..
ryuzaki012012-03-30 15:06:49
B
16
S
3
G
1
Posts: 3
Reputation: 954


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest