[Solved] Clickable behaviour

I am creating a Clickable Behaviour, which works fine as below:

Clickable behaviour source:

The implementation above does the job. However, it looks too hacky to me and I am not sure it’s the best approach.

I wonder if I could use something similar to GetArgumentAsString(“MOUSEBUTTON”) to evaluate the button clicked, instead of that chain of ANDs inside the OR in the first picture.

Any advice? Thanks!

The “mouse button” conditions won’t accept expressions, it seems.
You can split in three blocks if you want to get rid of the AND and ORs.
You’ll get three “Set to true” in exchange. :upside_down_face:

Is one approach better than the other in terms of stability or performance? If there is a benefit, I don’t mind having more events and return statements. It will be encapsulated in the extension anyways.

Shouldn’t amount to much, if there’s any difference.
You could try the performance profiler, see if you notice anything. :man_shrugging:

I exported both versions to HTML5 and compared. Profiling in Google Chrome, no significant difference, code-wise the 3-events approach generates a simpler code, which I guess is less prone to eventual bugs.

So I am going ahead with this instead:

1 Like