forgottenserver
forgottenserver copied to clipboard
Another type of search for Game.getSpectators
Pull Request Prelude
- [x] I have followed [proper The Forgotten Server code styling][code].
- [x] I have read and understood the [contribution guidelines][cont] before making this PR.
- [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
Changes Proposed
New type of search for the method Game.getSpectators
Types:
-
GROUND_FLOOR
: This represents what was previouslyfalse
, we search all viewers on the same level Z. -
UNDERGROUND_FLOOR
: This represents what wastrue
before, we look for all the spectators in all the Z levels. -
SURFACE_GROUND
: This is a new type of search, we search all spectators from level 0 to 7 only.
Issues addressed: #3322
Suggestions:
UNDERGROUND_FLOOR -> ALL_FLOORS SURFACE_GROUND -> SURFACE_FLOORS GROUND_FLOOR -> SAME_FLOOR
UNDERGROUND_FLOOR
is misleading as it's only looking at two floors above and below while underground, not all of them. I don't have a better name, though.
Some alternatives for UNDERGROUND_FLOOR
EXTENDED_FLOORS QUINTUPLE_FLOORS MULTI_FLOOR 5_FLOOR_SEARCH NEARBY_FLOORS
All of the above in arbitrary anyway. Why can't we change it to be user defined instead of hardcoded? range_z,
Some alternatives for UNDERGROUND_FLOOR
EXTENDED_FLOORS QUINTUPLE_FLOORS MULTI_FLOOR 5_FLOOR_SEARCH NEARBY_FLOORS
All of the above in arbitrary anyway. Why can't we change it to be user defined instead of hardcoded? range_z,
I've been thinking about it, already @yamaken93 suggested it too, it's not a bad idea so I'll think about it, I would also like to be able to define the Z range manually, I was just trying to keep the cache in the viewers, but I think because of how they go things, that cache will probably be removed later as apparently it is useless
Dont forget getSpectators
in
data/lib/compat/compat.lua
data/actions/scripts/other/die.lua
EDIT
I liked
MULTI_FLOOR
, SURFACE_FLOOR
, SAME_FLOOR
SUB_SURFACE would work for the third param and I think its pretty clear and concise in what it does, especially with the other options being like Dspeichert said:
SAME_FLOOR - that one is easy ABOVE_GROUND - because it's not just ground floor, it's all above it (floors 0-7)
Anyway it goes, if it gets changed with new params, We can just update the wiki to make sure its clear for what is each params intended use
Alternatively, we could just include a min and max for the z, like the x and y already has, with the minimum being the lowest floor to search, and max being the top floor to search, minimum defaulting to the current floor, and maximum defaulting to highest floor in map or same floor as well.
I think a raw api which allows you set from position and to position is good and versatile.
I think a raw api which allows you set from position and to position is good and versatile.
I second this. Trying to imagine every scenario will just lead to duplication and confusion.