Picking / SOL?

For developers using the Construct 2 Javascript SDK

Post » Wed Apr 08, 2015 4:33 pm

Is there a good place or plugin to look at to learn how to implement object picking?

I've been looking around a bit, and it's hard to tell what is and is not special-case picking code.
(Kind of the same way the function object has the "fast trigger" system that's not intended for general SDK use.)

Does anyone know of an SDK picking tutorial, or a plugin that has generally applicable picking code?

Part of the reason I'm interested is that I'm building a document full of template code snippets for various common ACE related tasks, such as looping, executing triggered conditions, and now picking and SOL manipulation, if I can figure it out.

Any thoughts or advice much appreciated, thanks. :)
B
26
S
17
G
8
Posts: 322
Reputation: 6,017

Post » Wed Apr 08, 2015 4:39 pm

A sample code to fill SOL with some uids.
B
107
S
25
G
228
Posts: 4,346
Reputation: 129,873

Post » Wed Apr 08, 2015 4:59 pm

Picking is pretty simple in principle: either select_all is true, in which case it uses all instances, or if it's false then it uses the instances in the SOL list. However the implementation details of this tend to be tricky.

Note you can only pick instances of the same object type or those which are referenced in object parameters - the event system does really important optimisations based on this assumption, but it means it won't work if you pick anything else. I'd also strongly recommend you don't pick anything outside of conditions, since it contradicts what the rest of C2 does. Ideally plugins can just stick to normal triggers and normal conditions.
Scirra Founder
B
381
S
222
G
84
Posts: 23,975
Reputation: 189,160

Post » Thu Apr 09, 2015 12:18 pm

Thanks Rex and Ashley for the info :)

I looked through the example code you posted, Rex,
and in the context of some of the things you said, Ashley,
I think I kind of see what's going on.

Is there a place in any of the runtime files I could look to see the implementation of the SOL system?
In particular I'd be interested to see a list of the available methods and fields you can use to interact with the SOL.
Kind of the SOL "interface".

Is a SOL attached to each C2 object type, and implemented as a SOL JavaScript object, assigned to a JavaScript field of the c2 object type?
Or is it something global to the entire runtime?
I might be misremembering, but it seems like I've been seeing things that looked to me like they could indicate that it's handled on a per C2 object type basis.
I haven't yet been able to track the references to the SOL far enough back upstream to see where they are originating from.

I also gather that there is a SOL stack that is used to store (for later restoration) SOL state as you recurs into deeper levels of events. Though again, I'm having trouble finding the actual code that would make it clear if that stack is a field of a C2 object type. I suspect that it might be in the commonace.js file, but I haven't been able to spend much time poking around in it yet.

Sorry for the noobly questions.
B
26
S
17
G
8
Posts: 322
Reputation: 6,017


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests