[Trick and API Request] Get objects in world.lua
Posted: Wed Nov 02, 2016 11:44 am
Priority: Low
world.lua is a good thing. I am using its WorkQueue to construct and build.
Sadly, it lacks a much-needed API for us to get objects by their type no matter where they are.
A workaround is as follows:
1. Spawn an anchor object to do nothing
2. Use .GetNearbyObjects of the anchor and pass a range parameter large enough (say 9999) to cover the whole map
3. After initialization, find and delete the old anchor when a save is loaded.
(Use .GetNearbyObjects('Anchor', 9999), returns two, keep this new one and delete the other.)
However, this anchor object will be annoying. Even .Hidden = true, it still can be hovered and has shadow when outdoors.
An improvement is:
2.5. Find the warden, make it play the role of anchor
3. Delete the initial anchor if a warden if found.
I will be glad if an API like World.GetObject() is added to save me from above ugly codes. But this workaround is quite fine, so the Priority is Low.
world.lua is a good thing. I am using its WorkQueue to construct and build.
Sadly, it lacks a much-needed API for us to get objects by their type no matter where they are.
A workaround is as follows:
1. Spawn an anchor object to do nothing
2. Use .GetNearbyObjects of the anchor and pass a range parameter large enough (say 9999) to cover the whole map
3. After initialization, find and delete the old anchor when a save is loaded.
(Use .GetNearbyObjects('Anchor', 9999), returns two, keep this new one and delete the other.)
However, this anchor object will be annoying. Even .Hidden = true, it still can be hovered and has shadow when outdoors.
An improvement is:
2.5. Find the warden, make it play the role of anchor
3. Delete the initial anchor if a warden if found.
I will be glad if an API like World.GetObject() is added to save me from above ugly codes. But this workaround is quite fine, so the Priority is Low.