ID:1997012
 
Redundant
Applies to:
Status: Redundant

This feature has already been implemented, or is already achievable with existing methods.
i wanna have some type of variable for images and movables that'll tell me how many mobs attached to clients are within world.view of this particular movable. would be really helpful especially for managing which kind of ai should be doing actions etc. just looking for a clean way without having to update active ai via for() or anything else

also if it could work for images that'd be neat too
++
Whilst you can effectively do hearers(), and just typecast clients, it would still be nice to have something for clients.

clients(ref,size = world.view)
proc/clients(DIST=0,turf/TURF){. = list();for(var/mob/M in hearers(TURF,DIST)){if(M.client){. |= M}};return .}
proc/oclients(DIST=0,turf/TURF){. = list();for(var/mob/M in ohearers(TURF,DIST)){if(M.client){. |= M}};return .}
Right, but if you have a three dozen mobs around you, and you're an AI only looking for clients, that's still excessive. Efficiency is the name of the game.
In response to Rushnut
Rushnut wrote:
Right, but if you have a three dozen mobs around you, and you're an AI only looking for clients, that's still excessive. Efficiency is the name of the game.

Seems redundant as the client isn't on the map but connected to the mobs, requiring you to look through the view anyway. Skill r name of game.
Ah! Good point! Clients aren't atom/movable, so therefor they don't exist on the map, so therefor you can't check for clients within a specific range, rather you'd have to check the mobs and any attached clients.

Request isn't feasible, but Kozuma's workaround is the best possible solution.
In response to Kozuma3
Kozuma3 wrote:
proc/clients(DIST=0,turf/TURF){. = list();for(var/mob/M in hearers(TURF,DIST)){if(M.client){. |= M}};return .}
> proc/oclients(DIST=0,turf/TURF){. = list();for(var/mob/M in ohearers(TURF,DIST)){if(M.client){. |= M}};return .}

return . is redundant here, as it's implicitly called by the procedure at the very end:

proc/add(a, b)
. = a + b

mob/Login()
..()
world << add(3, 4)

Actually, here's a slightly less CPU intensive method, assuming there's less clients connected than mobs within dist, otherwise Kozuma's is faster.

    clients(var/atom/ref,var/dist = 0)
. = new/list()
for(var/client/C)
if(C.mob)
if(get_dist(ref,C.mob) <= dist)
. |= C
Lummox JR resolved issue (Redundant)
In response to LordAndrew
ofc, it was just an example and I use return for readability.

In response to Kozuma3
Kozuma3 wrote:
proc/clients(DIST=0,turf/TURF){. = list();for(var/mob/M in hearers(TURF,DIST)){if(M.client){. |= M}};return .}
> proc/oclients(DIST=0,turf/TURF){. = list();for(var/mob/M in ohearers(TURF,DIST)){if(M.client){. |= M}};return .}

Kozuma3 wrote:
readability.

Choose one.


In response to Popisfizzy
Popisfizzy wrote:
Choose one.

It's a habit to use return at the end of procedures for me.

Those can be compressed as they're doing their purpose and most likely won't need modified.
In response to Kozuma3
That does not even begin to make them any more readable. "Compressed" is the antithesis of readability.
Gotta go with Pop here: No point compressing unless you're trying to put this in a #define or doing a 4K challenge, and putting return . at the end of a proc doesn't enhance readbility.

Also if you do have a need to compress, you don't want a semicolon after a closing brace.
In response to Lummox JR
Lummox JR wrote:
doing a 4K challenge

I looked at the Runt source once.

It's really a miracle Runt was made at all. It was darn near impossible to squeeze in all the functionality I did. SotS was actually easier in a lot of ways, but even that is chock full of features.
In response to Lummox JR
Lummox JR wrote:
putting return . at the end of a proc doesn't enhance readbility.

How can you say that tho when it's how I program? It helps me with readability, it might not help others but I find it useful :P
In response to Kozuma3
Kozuma3 wrote:
Lummox JR wrote:
putting return . at the end of a proc doesn't enhance readbility.

How can you say that tho when it's how I program? It helps me with readability

No it doesn't. It's bad form, nothing more.
In response to Lummox JR
Lummox JR wrote:
Kozuma3 wrote:
Lummox JR wrote:
putting return . at the end of a proc doesn't enhance readbility.

How can you say that tho when it's how I program? It helps me with readability

No it doesn't. It's bad form, nothing more.

Wats this got to do with readability tho?
Page: 1 2