The base function constructed in the first part of this series of posts takes a tuple — node_types to pull the instances and perform the matching. The last two sections went in detail on the types that will be searched for and why the defaults can be expected to be flagged on or off to avoid the most false positive results and remain the most useful. Below the new function and args are introduced…
If the last two sections were looked at these args and defaults should be of no surprise. The one exception is the last arg, ignore_ipr_cam, which will be explained in a moment.
Each arg’s flag is tested and the type append to a list, that eventually gets used as an arg for the base function. ie…
# check for light if flagged
After all the flagged on types are appended…
# look for matches
viewport_objects = list(viewportObjectsOfType(node_types))
There is a hidden camera node /obj/ipr_camera which will match the viewport transform. If you need to see it to believe it, go to the network editor, press CTRL+L and paste /obj/ipr_camera into the address bar and you will be inside the ipr cam node. Whenever we flag on cam as a type we are looking for, it will give us a false positive result, so we need to remove this from the results. As it is of a desired type, the easiest was it to check the name against ‘ipr_camera’.
# remove ipr_cam if flagged
for obj in viewport_objects:
if obj.name() == ‘ipr_camera’:
Lastly when there a results, they are returned as a tuple.
if len(viewport_objects) > 0:
result = tuple(viewport_objects)
And thats about it! It should now be clear on how to construct a usable function that return a light/cam matching the viewport transform matrix. The last section will look at what included in the download module and what is incorporated into eyevexTools.