Add on screen only option to getElementsByType#4746
Add on screen only option to getElementsByType#4746ArranTuna wants to merge 6 commits intomultitheftauto:masterfrom
Conversation
|
I like the idea, ill code-review it soon |
|
It just pollutes api with unnecessary parameters |
|
Fixed and re-tested. |
|
I wonder if we should instead have a new function that accepts a filter spec as the first parameter getElements({searchRoot = root, filterScreen = true, filterStreamedIn = true, filterTypes = ["vehicle", "player"]}) |
|
That way you can set |
There was a problem hiding this comment.
The current implementation of this pull request treats false as a free variable, when we should be treating nil as the free variable, and false as a fixed variable.
That way we don't need to add an extra "off screen only" parameter in the future.
I'm curious what you think about my proposal for a more general getElements function too.
|
I've started a discussion here: #4797 Lets discuss there how this API could look like and what the potential issues could be |
|
Guess I'll close this then. |
Summary
I suggested onClientElementEnterScreen #678 but in the comments suggested that an option in getElementsByType to return on screen only would be good.
Motivation
There are scripts that try to be more efficient by applying things to only elements that are on screen, for example a script that renders text above a players head currently would have to do getElementsByType("player", root, true) and call isElementOnScreen on that list, as this is being done every frame that's inefficient. This change allows you to just do: getElementsByType("player", root, true, true) to get only on screen elements.
Test plan
This is an easy to test change, at first I just compared the sizes of #getElementsByType("ped", root, true) and #getElementsByType("ped", root, true, true) while turning camera to see it worked correctly, I then used createBlipAttachedTo to make sure the actually on screen elements were the ones in the table.