I can pick objects using various events, of course, but there are some things that there aren’t events for (for example, picking by lowest z-order). I can handle this by writing a JavaScript code event, but then I have to handle all the subsequent things in JavaScript too, when there are perfectly normal GDevelop events that can do the work I want. Can I alter the picked object list in a JavaScript code event and then have that object list continue on to later events?
For example, imagine that I have:
The cursor/touch is on _Slices_
The text of variable _Activated_ of _Slices_ = "no"
-> action
Change the text of variable _Activated_ of _Slices_: set to "yes"
so mousing over a Slice sets a variable on it. That’s all good. However, in my game, lots of Slice objects overlap on the screen, and so mousing over a point where they overlap will activate all of them in that position. What I want to do is only activate the lowest one in the z-order. So ideally I want to do something like:
The cursor/touch is on _Slices_
(function(runtimeScene, objects /*Slices*/) {
// find the Slice with the lowest z-order
let lowestSlice; let lowestZ = 999999;
objects.forEach(slice => {
if (slice.getZOrder() < lowestZ) {
lowestZ = slice.getZOrder();
lowestSlice = slice;
}
});
runtimeScene.currentlyPickedObjectList = [lowestSlice];
})(runtimeScene, objects /*Slices */);
The text of variable _Activated_ of _Slices_ = "no"
-> action
Change the text of variable _Activated_ of _Slices_: set to "yes"
so my JavaScript can read the existing picked object list because it’s passed as objects, but then I want to set the existing picked object list so that that’s then passed on to the next event, which checks whether Variable(Activated) is set to “no”, and then my action will only affect the Slice which is lowest in the z-order.
Is this possible?