Thread Tools Display Modes
09-09-22, 02:54 PM   #1
hasnogaems
A Flamescale Wyrmkin
 
hasnogaems's Avatar
Join Date: Apr 2016
Posts: 109
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.
  Reply With Quote
09-09-22, 03:15 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
GetNetStats() returns multiple values. The Select used like that just picks out the 4th one.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-09-22 at 03:19 PM.
  Reply With Quote
09-09-22, 03:15 PM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by hasnogaems View Post
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
  Reply With Quote
09-09-22, 04:02 PM   #4
hasnogaems
A Flamescale Wyrmkin
 
hasnogaems's Avatar
Join Date: Apr 2016
Posts: 109
But what are .. .. do? Just spaces?
  Reply With Quote
09-09-22, 04:13 PM   #5
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by hasnogaems View Post
But what are .. .. do? Just spaces?
text concatenation
  Reply With Quote
09-09-22, 06:19 PM   #6
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » What this command do?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off