Completed Auxbox Codes

Moderator: EUO Moderators

User avatar
Keighn
Stop posting already --;
Posts: 5387
Joined: Sat Jun 26, 2004 10:13 am
Location: Hey.... pssttt Back in Orgeon

Re: Completed Auxbox Codes

Post by Keighn » Fri Dec 26, 2014 12:45 am

I don't recall if I ever redound that thread. Maybe someday the manual will be updated with all the aux codes posted.

Celerion
LAUGHING OUT LOUD LIKE A MORON
Posts: 64
Joined: Sat Dec 15, 2012 6:29 am

Re: Completed Auxbox Codes

Post by Celerion » Sat Dec 27, 2014 3:20 am

Just wanted to point at my version of auxbox.lua.

Unfortunately I didn't know about your framework (if that's the correct word for it), I just looked into the .lua-file that comes with the client one day and thought, well, that looks ugly. I also wanted to understand what was going on there, so I learnt some Lua. Finally, I rewrote the file in a way, I'd do it (coming from Python). I even took an object-orientated approach (like I would in Python), but I admit, that isn't really necessary for that file.

- My version shows the time to next double-XP on reg, starting 7 days before it. If only one day is left, it shows the hours. While double-XP is on, it shows the time until it is switched off again. This works much better (and easier) now since the server was set to universal time.

- You can also configure the behaviour of the script with the global variables at the beginning (the ones in capital letters). They can be set to either "true" or "false".

User avatar
CIAassassin
Tune in next time & see how they do it.
Posts: 598
Joined: Thu Oct 26, 2006 10:34 am

Re: Completed Auxbox Codes

Post by CIAassassin » Sat Dec 27, 2014 9:58 am

yea bro, no framework here I was just copy-pasting individual code blocks. I stopped when you started making your code generator as I had no clue how to post/break that down
Rikimaru

"Oh, you're a lesbian? That's cool, I'm a lesbian trapped in a mans body, we should date."

Celerion
LAUGHING OUT LOUD LIKE A MORON
Posts: 64
Joined: Sat Dec 15, 2012 6:29 am

Re: Completed Auxbox Codes

Post by Celerion » Tue Dec 30, 2014 11:13 am

CIAassassin wrote:yea bro, no framework here I was just copy-pasting individual code blocks. I stopped when you started making your code generator as I had no clue how to post/break that down
So if I get you correctly, you'd like to have the code in a format that fits to this, right?
Not much of a problem, I just took out the double-xp-stuff and rewrote it in that way (I call my file "cel_doublexptime.lua", should go into your clientscripts-folder, you know, with 0_auxbox.lua in it):

Code: Select all

ched_addon_register("Double-XP-time", "Celerion", "1.0", "double_xp_time_1", "double_xp_info()")

-- cel_doublexptime.lua - Double-XP-time, by Celerion, 12-2014.

-- Shows days to Double-XP (which is on first weekend each month).
-- If there's only one day left, the hours to Double-XP are shown.
-- If Double-XP is on, the time until it is switched off again is shown.

function double_xp_info()

    local double_xp_info_with_days    = false
    local double_xp_info_with_seconds = true
    local show_days_to_double_xp      = true
    local show_hours_to_double_xp     = true
    local days_in_advance             = 7

    local oneday = 86400
    local twodays = 172800
    local utcttable = os.date("!*t")
    local restsecs = 0
    local days = 1
    local secs = 0
    local utcseconds = 0
    local t = {}
    local timestr = ""

    -- For testing:
    -- utcttable.wday = 6
    -- utcttable.day = 3
    -- utcttable.hour = 0
    -- utcttable.min = 0
    -- utcttable.sec = 0

    -- Do we have Double-XP? (For wday, Saturday is 7, Sunday is 1):
    if utcttable.wday == 7 and utcttable.day < 8 or
       utcttable.wday == 1 and utcttable.day <= 8 and utcttable.day >= 2
    then
        restsecs = twodays - (utcttable.hour * 3600 + utcttable.min * 60 + utcttable.sec)
        -- Sunday - One day has already passed:
        if utcttable.wday == 1 then
            restsecs = restsecs - oneday
        end
        timestr = seconds_to_time_string(restsecs, double_xp_info_with_days, double_xp_info_with_seconds)
        auxbox_prop_line("Double-XP:", timestr)
        -- auxbox_blank_line()
        return
    end

    -- Double-XP in next days?
    if show_days_to_double_xp ~= true then
        return
    end
    utcseconds = os.time(utcttable)
    while days <= days_in_advance do
        secs = utcseconds + oneday * days
        t = os.date("*t", secs)
        if t.wday == 7 and t.day < 8 then
            break
        end
        days = days + 1
    end

    if days > 1 then
        if days <= days_in_advance then
            auxbox_prop_line(days .. " days until Double-XP.")
            -- auxbox_blank_line()
        end
        return
    end

    auxbox_prop_line("Tomorrow's Double-XP.")

    if show_hours_to_double_xp ~= true then
        return
    end
    restsecs = oneday - (utcttable.hour * 3600 + utcttable.min * 60 + utcttable.sec)
    timestr = seconds_to_time_string(restsecs, false, false)
    auxbox_prop_line("Hours to Double-XP:", timestr)
    -- auxbox_blank_line()
end


function seconds_to_time_string(secs, show_days, show_secs)
    local oneday = 86400
    local onehour = 3600
    local oneminute = 60
    local rest = 0
    local tstr = ""
    local t = {}
    if show_days == true then
        t.days = math.floor(secs / oneday)
        rest = secs - t.days * oneday
        t.hours = math.floor(rest / onehour)
        rest = rest - t.hours * onehour
        tstr = string.format("%02d:%02d:", t.days, t.hours)
    else
        t.hours = math.floor(secs / onehour)
        rest = secs - t.hours * onehour
        tstr = string.format("%02d:", t.hours)
    end
    t.mins = math.floor(rest / oneminute)
    rest = rest - t.mins * oneminute
    t.secs = math.floor(rest)
    if show_secs == true then
        tstr = tstr .. string.format("%02d:%02d", t.mins, t.secs)
    else
        tstr = tstr .. string.format("%02d", t.mins)
    end
    return tstr
end
Last edited by Celerion on Tue Jan 06, 2015 7:28 am, edited 1 time in total.

Celerion
LAUGHING OUT LOUD LIKE A MORON
Posts: 64
Joined: Sat Dec 15, 2012 6:29 am

Re: Completed Auxbox Codes

Post by Celerion » Fri Jan 02, 2015 2:09 am

In the default auxbox.lua-file, there was also some useful damage-per-second-code by LordMortiferus. As far as I can see, he didn't put it into the "framework"-format yet. So I took an approach with his code. The file should be called "LM_dps.lua" (if Mort agrees, that his "LM_"-prefix is used):

Code: Select all

ched_addon_register("Damage Per Second", "LordMortiferus, Celerion", "01-05-2015", "lm_damage_per_second_1", "auxbox_damage_per_second()")

-- LM_dps.lua - Damage per second - Shows the damage per second dealt
-- and taken in the auxbox.
-- Original code by LordMortiferus, modified by Celerion.

---------

-- This global stuff is run once at startup. Then, the variables are changed
-- repeatedly, when the function is called:

euo_sessionstart = os.time()
last_session_seconds = 0

from_euo = {}
from_euo.g_dpst = g_dpst
from_euo.g_dtpst = g_dtpst
last_4_dpst = {}
for i = 1, 4 do
    table.insert(last_4_dpst, from_euo.g_dpst)
end
last_4_dtpst = {}
for i = 1, 4 do
    table.insert(last_4_dtpst, from_euo.g_dtpst)
end
last_dpst = from_euo.g_dpst
recent_dmg = {0, 0, 0, 0}


function auxbox_damage_per_second()

    local show_damage_dealt_per_second_line   = true
    local show_damage_taken_per_second_line   = true
    local show_recent_damage_dealt_lines      = false

    local session_seconds = os.difftime(os.time(), euo_sessionstart)

    from_euo.g_dpst = g_dpst
    from_euo.g_dtpst = g_dtpst

    if session_seconds > last_session_seconds then
        last_session_seconds = session_seconds
        last_4_dpst[4] = last_4_dpst[3]
        last_4_dpst[3] = last_4_dpst[2]
        last_4_dpst[2] = last_4_dpst[1]
        last_4_dpst[1] = from_euo.g_dpst   
        last_4_dtpst[4] = last_4_dtpst[3]
        last_4_dtpst[3] = last_4_dtpst[2]
        last_4_dtpst[2] = last_4_dtpst[1]
        last_4_dtpst[1] = from_euo.g_dtpst   
    end
   
    if last_dpst ~= from_euo.g_dpst then
        recent_dmg[4] = recent_dmg[3]
        recent_dmg[3] = recent_dmg[2]
        recent_dmg[2] = recent_dmg[1]
        recent_dmg[1] = from_euo.g_dpst - last_dpst
        last_dpst = from_euo.g_dpst
    end
   
    if show_damage_dealt_per_second_line == true then
        auxbox_prop_line("Dmg Dealt / Sec", string.format("%d", (last_4_dpst[1] - last_4_dpst[4])  / 4))
    end
    if show_damage_taken_per_second_line == true then
        auxbox_prop_line("Dmg Taken / Sec", string.format("%d", (last_4_dtpst[1] - last_4_dtpst[4])  / 4))
    end
    if show_recent_damage_dealt_lines == true then
        auxbox_prop_line("Recent Dmg Dealt", "")
        auxbox_prop_line("", string.format("%d  %d  %d  %d", recent_dmg[4], recent_dmg[3], recent_dmg[2], recent_dmg[1]))
    end
end

Celerion
LAUGHING OUT LOUD LIKE A MORON
Posts: 64
Joined: Sat Dec 15, 2012 6:29 am

Re: Completed Auxbox Codes

Post by Celerion » Tue Jan 06, 2015 7:31 am

Additionaly, here's the config-file with the settings, I find useful at the moment. The file has to be in the EUO-directory ("C:\...\euo") and has to be called "config_Yourcharactername.lua", where "Yourcharactername" is the name of your character, obviously, so for me the file is called "config_Celerion.lua" for example. Of course, you can also create your own config-file using the included auxbox-menu which can be activated with Alt+m (good work, CIAassassin!):

Code: Select all

return {
-- Table: {1}
{
   "brentoboy_rwt_1",
   "euo_sessiontime_1",
   "euo_blank_line_1",
   "double_xp_time_1",
   "euo_blank_line_2",
   "ched_xp_tnl_1",
   "euo_blank_line_3",
   "lm_damage_per_second_1",
},
}

Post Reply