WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Can you get the servers name? (https://www.wowinterface.com/forums/showthread.php?t=30664)

ShetiPhian 02-14-10 12:33 PM

Can you get the servers name?
 
I use Stuf Unit Frames and would like to replace the (*) that appears after a players name with the server name.

I'm sure I need to use the Custom Lua option but don't know the script :rolleyes:

Cralor 02-14-10 12:43 PM

Try this:

GetServerName();

Code:

local serverName = GetServerName();

ShetiPhian 02-14-10 02:17 PM

so simple, now I feel dumb :o

Thankyou :)

ShetiPhian 02-14-10 03:21 PM

um.. I must need something inside of the ()


This returns nothing:
Code:

function(unit, cache, textframe) local servername = GetServerName() return servername end

This returns Server
Code:

function(unit, cache, textframe) local servername = "Server" return servername end

now to find whats missing

xConStruct 02-14-10 03:25 PM

Are you looking for UnitName?
Code:

local name, realm = UnitName(unit)
I've never come across GetServerName(), I only know GetRealmName()

Cralor 02-14-10 03:28 PM

Hmm... you know, I thought the same thing. Looks like I'll have to delete that WoWWiki article with false information.

Shadowed 02-14-10 04:07 PM

You can just use the function Blizzard adds in UnitFrame.lua:

Code:

function GetUnitName(unit, showServerName)
        local name, server = UnitName(unit);
        if ( server and server ~= "" ) then
                if ( showServerName ) then
                        return name.." - "..server;
                else
                        return name..FOREIGN_SERVER_LABEL;
                end
        else
                return name;
        end
end

So GetUnitName("target", true) will show the full name and server if they target is from a different one.

ShetiPhian 02-14-10 05:33 PM

So I think changing the code in core.lua will work better then trying the built in custom lua box.

I found this in core.lua
Code:

local function GetUnitName(unit)
        local name, server = UnitName(unit)
        if server and server ~= "" then
                return name..FOREIGN_SERVER_LABEL
        else
                return name
        end
end

and I changed it to this:
Code:

local function GetUnitName(unit)
        local name, server = UnitName(unit)
        if server and server ~= "" then
                return name.." - "..server
        else
                return name
        end
end

I'm sitting in queue now, hope it works.

ShetiPhian 02-14-10 06:39 PM

That worked, Thank you for all the help!


All times are GMT -6. The time now is 02:32 PM.

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