WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   What this command do? (https://www.wowinterface.com/forums/showthread.php?t=59208)

hasnogaems 09-09-22 02:54 PM

What this command do?
 
What this command do?
/run print("Current Latency: "..select(4,GetNetStats()).."ms.")
What .. .. mean around select(4,GetNetStats()) and how select(4,GetNetStats()) function works exactly to be specific.

Fizzlemizz 09-09-22 03:15 PM

GetNetStats() returns multiple values. The Select used like that just picks out the 4th one.

Dridzt 09-09-22 03:15 PM

Quote:

Originally Posted by hasnogaems (Post 340959)
What this command do?
/run print("Current Latency: "..select(4,GetNetStats()).."ms.")
What .. .. mean around select(4,GetNetStats()) and how select(4,GetNetStats()) function works exactly to be specific.

https://wowpedia.fandom.com/wiki/API_GetNetStats

and select(4 means it's selecting the 4th return from that method ie latencyWorld

hasnogaems 09-09-22 04:02 PM

But what are .. .. do? Just spaces?

Dridzt 09-09-22 04:13 PM

Quote:

Originally Posted by hasnogaems (Post 340962)
But what are .. .. do? Just spaces?

text concatenation

Kanegasi 09-09-22 06:19 PM

To explain "concatenation" in terms of code, the double period takes two strings (or numbers) and binds them together into one.

The fourth return of GetNetStats is your latency to the current instance server your character is at, which affects movement of players and NPCs around you as well as your interactions with them, such as vendors and combat. This return is a number.

This means that:
"Current Latency: "..select(4,GetNetStats()).."ms."
Will turn into (pretend your world latency is 100ms):
"Current Latency: "..100.."ms."
Then the first double period will bind the first two:
"Current Latency: 100.."ms."
Then the second double period:
"Current Latency: 100ms."
So the original command effectively does this, but automatically updates the number:
/run print("Current Latency: 100ms.")
/run is the same as /script, everything after the command is treated as Lua and is executed, print() dumps what it is given into ChatFrame1 in white text.


All times are GMT -6. The time now is 04:08 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI