Seriously What is the Client.lua purpose?

1 posts · 2006-05-20 05:02:00 to 2006-05-20 05:02:00

#12200014486 05/20/2006 05:02 Seriously What is the Client.lua purpose?



I want to clean my computer up of usless files and as
far as im concerned i dont think this is even used anymore correct? So
is it ok if i delete this file?



Here is its contents:


--

-- Config variables

--



-- variables to track XP

ExperienceStats = {};

totalExperience = 0;



-- variables to track $INFO

InfoStats = {};

totalInfo = 0;



-- variables to track combat

CombatStats = {};

totalDmg = 0;

InCombat = 0;

DPS = 0;



--

-- Add time stamp to chat messages

--

function OnChatHandler(text)

    text = time + text

end



--

-- Accumulate XP data

--

function AddExperience(xp, source)

    totalExperience = totalExperience + xp;

    

    if (ExperienceStats[source] == nil) then

        ExperienceStats[source] = xp;

    else

        ExperienceStats[source] = ExperienceStats[source] + xp;

    end

end



--

-- Accumulate $info data

--

function AddInfo(info, source)

    totalInfo = totalInfo + info;

    

    if (InfoStats[source] == nil) then

        InfoStats[source] = info;

    else

        InfoStats[source] = InfoStats[source] + info;

    end

end



--

-- Accumulate combat data

--

function AddDamageOther(action, dmg, target)

    totalDmg = totalDmg + dmg;



    if (CombatStats[action] == nil) then

        CombatStats[action] = dmg;

    else

        CombatStats[action] = CombatStats[action] + dmg;

    end



    -- calculate combat DPS

end



--

-- Handler for system chat messages

--

function OnSystemChat(subtype, text)

    -- important messages

    if (subtype == "CT_SYS_IMPORTANT") then

        for xp, source in string.gfind(text, "You gained (%d+) experience from (.+)") do

            AddExperience(xp, source);

            return;

        end



        for item, info in string.gfind(text, "You buy a (.+) for (%d+) info") do

            AddInfo(-info, "buy from vendor");

            return;

        end        

    

        for item, info in string.gfind(text, "You sell the (.+) for (%d+) info.") do

            AddInfo(info, "sell to vendor");

            return;

        end        

        

    end

    

    -- loot messages

    if (subtype == "CT_SYS_LOOT") then

        for action, info, source in string.gfind(text, "You (.+) (%d+) information from (.+)") do

            AddInfo(info, source);

            return;

        end        

    end



    -- combat damage to yourself

    if (subtype == "CT_SYS_COMBAT_DMG_SELF") then

    end



    -- combat damage to another

    if (subtype == "CT_SYS_COMBAT_DMG_OTHER") then

        for action, dmg, target in string.gfind(text, "Your (.+) does (%d+) damage to (.+).") do

            AddDamageOther(action, dmg, target);

            return;

        end

    end

end



--

-- called when the client starts up

--

function OnStartup()

--    client.MsgBox("OnStartup", "woot!");

end



--

--

--

function LogSessionXP()

    local f = assert(io.open("xpstats.txt", "w"));

    

    f:write("Total XP: ", totalExperience, "\n\n");

    

    for k, v in pairs(ExperienceStats) do

        f:write(k, ": ", v, "\n");

    end

    

    f:close();

end



--

--

--

function LogSessionInfo()

    local f = assert(io.open("infostats.txt", "w"));

    

    f:write("Total $i: ", totalInfo, "\n\n");

    

    for k, v in pairs(InfoStats) do

        f:write(k, ": ", v, "\n");

    end

    

    f:close();

end



--

--

--

function LogCombatInfo()

    local f = assert(io.open("combatstats.txt", "w"));

    

    f:write("Total damage: ", totalDmg, "\n\n");

    

    for k, v in pairs(CombatStats) do

        f:write(k, ": ", v, "\n");

    end

    

    f:close();

end



--

-- called when the client shuts down

--

function OnShutdown()

    LogSessionXP();

    LogSessionInfo();

    LogCombatInfo();

end



--

-- called when player exits the world

--

function OnExitWorld()

    LogSessionXP();

    LogSessionInfo();

    LogCombatInfo();

end