Custom Auxbox Creations

Moderator: EUO Moderators

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

Custom Auxbox Creations

Post by CIAassassin » Wed May 08, 2013 6:09 am

So this thread is for custom auxbox creations. Basically a coming together of the minds to make the most "useful to all situations" auxbox. Post up some of the codes you use (with proper credit given in the comment lines of the code) and use this thread to make requests and get advice on how to put different codes together to streamline the codes you use to you.

Code: Select all

    session_start = os.time() - 1
    auxbox_next_line = 0

    function auxbox()
       
       d:auxbox_clear();
       auxbox_next_line = 0
          
       auxbox_real_world_time()   
       auxbox_blank_line()   

       auxbox_damage_per_second()
       auxbox_blank_line()
       
       auxbox_xp()
            auxbox_blank_line()   

       auxbox_monk_conditionals()
       auxbox_blank_line()

       auxbox_f5_message()   
    end

    function auxbox_prop_line(prop_name, prop_val)
        local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
       auxbox_next_line = auxbox_next_line + 1
       d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
    end

    function auxbox_blank_line()
       auxbox_next_line = auxbox_next_line + 1
    end

    function auxbox_real_world_time()
       auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
    end

    function auxbox_monk_conditionals()
       if me:fists_or_fist_weapons() and me:is_unarmoured() then
          auxbox_prop_line("Unarm/UA:", "True/True")
       elseif not me:fists_or_fist_weapons() and me:is_unarmoured() then
          auxbox_prop_line("Unarm/UA:", "False/True")
       elseif me:fists_or_fist_weapons() and not me:is_unarmoured() then
          auxbox_prop_line("Unarm/UA:", "True/False")
       elseif not me:fists_or_fist_weapons() and not me:is_unarmoured() then
          auxbox_prop_line("Unarm/UA:", "False/False")
       end
    end

    -- Damage Per Second (by Severian)
    -- starts displaying DPS after 35 hits, and gets more accurate the more hits you make
    -- assumes few intervals walking and more intervals between continuous hits

    VERBOSE_DPS_REPORT = true
    last_dpst = g_dpst
    hits_recorded = 0
    dmg_log = {}
    median_damage = -1
    recent_hit_times = {}
    five_hit_intervals = {}
    median_interval = -1

    function auxbox_damage_per_second()
       local current_time
       local current_dmg
       local current_five_hit_interval
       local temp_var
       local temp_five_hit_intervals
       local temp_dmg_log
       if last_dpst ~= g_dpst then
          current_time = os.time()
          current_dmg = g_dpst - last_dpst
          hits_recorded = hits_recorded + 1
          if hits_recorded <= 30 then -- first 30 hits
             table.insert(dmg_log, 1, current_dmg)
          else -- on and after the 31st hit
             table.remove(dmg_log, 30)
             table.insert(dmg_log, 1, current_dmg)
          end
          last_dpst = g_dpst
          if hits_recorded < 6 then -- first 5 hits
             table.insert(recent_hit_times, 1, current_time)
          else -- on and after the 6th hit
             table.remove(recent_hit_times, 5)
             table.insert(recent_hit_times, 1, current_time)
          end
          if hits_recorded >= 5 then
             current_five_hit_interval = recent_hit_times[1] - recent_hit_times[5]
             if hits_recorded <= 35 then -- first 30 "5 hit" intervals
                table.insert(five_hit_intervals, 1, current_five_hit_interval)
             else -- on and after the 31st "5 hit" interval
                table.remove(five_hit_intervals, 30)
                table.insert(five_hit_intervals, 1, current_five_hit_interval)
             end
          end
       end
       if hits_recorded < 35 then
          temp_var = 35 - hits_recorded
          auxbox_prop_line("DPS:", string.format("...in %d hits...", temp_var))
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Median Damage:", "") end
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Median 5-Hit Time:", "") end
       else
          temp_dmg_log = {}
          for i,v in pairs(dmg_log) do
             temp_dmg_log[i] = v
          end
          table.sort(temp_dmg_log)
          temp_five_hit_intervals = {}
          for i,v in pairs(five_hit_intervals) do
             temp_five_hit_intervals[i] = v
          end
          table.sort(temp_five_hit_intervals)
          median_damage = math.ceil((temp_dmg_log[15] + temp_dmg_log[16]) / 2)
          median_interval = math.floor((temp_five_hit_intervals[15] + temp_five_hit_intervals[16]) / 2)
          temp_var = math.floor((median_damage * 5) / median_interval)
          auxbox_prop_line("DPS:", string.format("%d", temp_var))
          if VERBOSE_DPS_REPORT then
             auxbox_prop_line("Median Damage:", string.format("%d", median_damage))
          end
          if VERBOSE_DPS_REPORT then
             auxbox_prop_line("Median 5-Hit Time:", string.format("%d", median_interval))
          end
       end
    end

    function auxbox_f5_message()
       auxbox_prop_line("Press F5 to Reset", "")
    end

    session_start_xp = me.xp -- var to calculate xp gain per session
    session_start_age = me.age -- var to calculate time played per session
    session_time = 0
    current_level = 0

    -- beginning of XP-array
    req_xp = {}
    req_xp[1] = 0 -- fixed XP value
    req_xp[2] = 200 -- fixed XP value
    req_xp[26] = 93000 -- fixed XP value

    for i=3,25 do -- adds XP for lvl 3 to 25 to array
      req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
    end

    for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
      req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
    end

    if me.xp >= req_xp[1000] then
       current_level = 1000
    else
       for i = 1,999 do -- getting current player level based on array
          if req_xp[i] <= me.xp
          and req_xp[i + 1] > me.xp
          then
             current_level = i
             break
          end
       end
    end

    -- end of XP-array

    function auxbox_xp()
       if current_level <= 1000 then
          local xptolvl_float = ((me.xp - req_xp[current_level]))/(req_xp[current_level+1]-req_xp[current_level]) -- % needed for next level
          local lvl_float = current_level + me.remort_level * 75 + xptolvl_float -- combines actual lvl with the % needed for next lvl

           -- checks if player leveled or remorted
          if xptolvl_float >= 1 or xptolvl_float < 0 then
             for i = 1,999 do
                if req_xp[i] <= me.xp
                and req_xp[i + 1] > me.xp
                then
                   current_level = i
                   break
                end
             end
          end
          
          if os.difftime(os.time(), session_start) > session_time then -- just to reduce the script to every second
             session_time = os.difftime(os.time(), session_start)
             session_d_float = session_time / 60 / 60 / 24
             session_d = math.floor(session_d_float)
             session_h = math.floor((session_d_float - session_d)*24)
             session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
             session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)

             xpgain = me.xp - session_start_xp 
             xps = xpgain/session_time

             if me.age-session_start_age > 0  then
               xpmin = xpgain/(me.age-session_start_age)
             else
               xpmin = 0
             end

             xptolvl = req_xp[current_level + 1] - me.xp
             xpto1k = req_xp[1000] - me.xp

             if xps > 0 then
               timetolvl = xptolvl / xps
               timeto1k = xpto1k / xps
             else
               timetolvl = 0
               timeto1k = 0
             end

             timetolvl_d_float = timetolvl / 60 / 60 / 24
             timetolvl_d = math.floor(timetolvl_d_float)
             timetolvl_h = math.floor((timetolvl_d_float - timetolvl_d)*24)
             timetolvl_m = math.floor(((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60)
             timetolvl_s = math.floor((((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60 - timetolvl_m) * 60)

             timeto1k_d_float = timeto1k / 60 / 60 / 24
             timeto1k_d = math.floor(timeto1k_d_float)
             timeto1k_h = math.floor((timeto1k_d_float - timeto1k_d)*24)
             timeto1k_m = math.floor(((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60)
             timeto1k_s = math.floor((((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60 - timeto1k_m) * 60)
          end
          
          
          --auxbox_prop_line("Level" ,string.format("%f",lvl_float))
          --auxbox_prop_line("Time" ,string.format("%02.f:%02.f:%02.f:%02.f", session_d, session_h, session_m, session_s))
     
          --auxbox_prop_line("Current XP", string.format("%d", me.xp))
          auxbox_prop_line("XP to Level:", string.format("%d", xptolvl))
          --auxbox_prop_line("XPgain" ,string.format("%d", xpgain))
          --auxbox_prop_line("XP/s" ,string.format("%d", xps))
          auxbox_prop_line("XP per Minute:" ,string.format("%d", xpmin))
     
          auxbox_prop_line("Time to Level:" ,string.format("%02.f:%02.f:%02.f:%02.f", timetolvl_d, timetolvl_h, timetolvl_m, timetolvl_s))
          --auxbox_prop_line("Time to L1000:" ,string.format("%02.f:%02.f:%02.f:%02.f", timeto1k_d, timeto1k_h, timeto1k_m, timeto1k_s))
          
       end
    end

Code: Select all

auxbox_next_line = 0
session_time = 0
sessionstart = os.time()

shiftkeys={"Shift","Alt","Ctrl+Shift","Shift+Alt","Ctrl+Alt","Ctrl+Alt+Shift"}

player_xp=me.xp
player_currentlvl=me.lvl
player_lastxp=0
player_startxp=player_xp
--player_session_minutes = 0
--player_xp_p_min = 0
player_xp_next_level = 0
player_xp_p_fmin = 0
player_xp_p_tmin = 0
player_xp_lasttickxp = me.xp
player_lasttick= 0
player_xp_arr={}
for i=1,600 do
   player_xp_arr[i]=0
end

-- XP by LordMortiferus 2013/01/28, rehashed by Brentoboy
-- snip snip
-- beginning of XP-array
req_xp = {}
req_xp[1] = 0 -- fixed XP value
req_xp[2] = 200 -- fixed XP value
req_xp[26] = 93000 -- fixed XP value

for i=3,25 do -- adds XP for lvl 3 to 25 to array
  req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
end

for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
  req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
end

-- snip snip

-- end of XP-array
player_arga=0
player_argb=0
player_argc=0
player_arg1=0
player_arg2=0
player_arg3=true

function incargs()
   for i=0x00,0xff do
      if items:get_qty(make_code(1103,0,player_arg2,i)) == 175 then
         player_arga=player_arg1
         player_argb=player_arg2
         player_argc=i
         player_arg3=false
         return
      end
   end
   player_arg2=player_arg2+1
   --if player_arg2==256 then
   --   player_arg2=0
   --   player_arg1=player_arg1+1
   --end
   if player_arg2==0xff then
      player_arg3=false
      return
   end
end

function auxbox()
   
  local w=d:auxbox_get_width()
  local h=d:auxbox_get_height()
 
  d:auxbox_clear()
  auxbox_next_line = 0
  if not d:ok_to_draw_play_window() then return; end
     
  local cd=d:get_curr_display()
  local mode=d:get_statbox_mode()
  local lineNr=0
  local txta=explode("\n", filterTextLines)
  if cd==1 then
 
    if mode==SELECT_ABILITY then
       auxbox_prop_line("Hit F-key to bind currently")
       auxbox_prop_line("selected spell")
       auxbox_blank_line()
       auxbox_ability_binds()
    else
 
        for i=1,#txta do
         auxbox_prop_line(txta[i])
        end
        auxbox_blank_line()
        auxbox_prop_line("Search with /")
        if mode==SELECT_READY then
           auxbox_prop_line("Press ENTER to equip")
       elseif mode==SELECT_BUY then        
          auxbox_prop_line("Press ENTER to buy")
       elseif mode==SELECT_BANK then
          auxbox_prop_line("Press ENTER to transfer one")
          auxbox_prop_line("Press Shift+ENTER for 10")
          auxbox_prop_line("Press TAB for whole stack")
       end
     end
   
  else
           
         --auxbox_time()   --Not really interesting
         --auxbox_blank_line()
         --auxbox_prop_line("XP TNL:", player_xp_next_level)  
         --auxbox_blank_line()
         XP_Calc()
		 --auxbox_prop_line(me.id)
         --auxbox_blank_line()
         DPS_Calc()
         --auxbox_blank_line()
         Items_Left()
         auxbox_blank_line()
         auxbox_damage_per_second()
         --auxbox_blank_line()
         --auxbox_bound_item_basecodes()
         --auxbox_prop_line(wl:get_full_name(make_code(1334,0xd,0x02,0x12)))
         --auxbox_prop_line(wl:get_full_name(make_code(0x44f,0x0,0x00,0x0)))
         --auxbox_prop_line("qty:", items:get_qty(make_code(0x44f,0x0,0x74,0x75)))
         --testitem(make_code(0x1000044f,0x0,0x0,0))
         --auxbox_prop_line(me.id)
         --auxbox_prop_line(string.format("%.2f",STAT_VALUE))
         --if player_arg3 then
         --   auxbox_prop_line(string.format("%x %x",player_arg1,player_arg2))
         --   incargs()
         --end
         --auxbox_prop_line(string.format("%x %x %x",player_arga,player_argb,player_argc))
                  

       
        --if d:numlock() then
           --auxbox_blank_line()
           --auxbox_prop_line("Please turn numlock off!")
        --end
       --auxbox_blank_line()
        --auxbox_prop_line("F12 for main menu.")
        --auxbox_blank_line()
         --auxbox_f5_message()
  end
   
     
end

function testitem(code)
   auxbox_prop_line(wl:get_full_name(code))
   auxbox_prop_line(items:get_qty(code))
end

--
--make_code(basecode,material,arg1,arg2)
--arg1: 1-14 affix arg2=quantity
--arg1: 0 magic ench, arg2= spell id
--arg1: 15 prefix, arg2=quality (improved,refined,greater,superior,magic,enchanted,etc.)
--
--
--
--arg2: for meat - 0x1? charred, 0x2?, roasted, 0x?1 item, 0x?2 mob, 0x?3 mob.
--if the first bit is 1, it'll be cursed
--continues into arg1 and material. probably makes more sense if you look at the finished item code.
--probably assembles it like thus: 0xBBB2211MM --- actually 0x2211MMBBB?
--
--
--

-- Color codes:
-- 16(0x10) - white
-- 17(0x11) - yellow(?) tinted white
-- 18(0x12) - light blue
-- 19(0x13) - red
-- 20(0x14) - light orange
-- 21(0x15) - light green
-- 22(0x16) - light purple/pink
-- 23(0x17) - cyan(?)
-- 24(0x18) - gray(dark, ie. log in/out messages)
-- 25(0x19) - orange
-- 26(0x1A) - living (light) green
-- 27(0x1B) - Yellow
-- 28(0x1C) - Purple
-- 29(0x1D) - green
-- 30(0x1E) - green
-- 31(0x1F) - Runic alphabet
--

function auxbox_bound_item_basecodes()
   local item
   local name
   for i = 1, 50 do   
      item = me.item_binds[i]
      name = wl:get_full_name(item)
      
      if item
      and not wl:is_tool(item)
      and name ~= "NOTHING"
      then
         --auxbox_prop_line(lua_gettable(item,1))
         --auxbox_prop_line(array.get(item,5))   
         auxbox_prop_line(name, get_base_code(item))
      end
   end
end

function XP_Calc()
   if player_xp<me.xp then
      player_lastxp=me.xp-player_xp
      player_xp=me.xp
   end
   --if player_lastxp > 50000
   --or player_lastxp < 0 then
   --   player_current_lvl = me.lvl
   --   player_last_xp = 0
   --   return
   --end
      
   if (os.difftime(os.time(), player_lasttick)>=1) then --We need to run this once per second
      --player_session_minutes = (os.difftime(os.time(), sessionstart)/60)
      --player_xp_p_min = math.floor(((player_startxp-player_xp)*-1)/player_session_minutes)
      player_xp_next_level = (req_xp[(player_currentlvl+1)]-me.xp)
      if player_xp_next_level < 0 then
         player_currentlvl = player_currentlvl + 1
      end
      
      local xpperminuteftotal = 0
      local xpperminutettotal = 0
      for i=1,300 do --5 to 10 minutes back
         player_xp_arr[(600-(i-1))]=player_xp_arr[(600-i)]
         xpperminutettotal=xpperminutettotal+player_xp_arr[(600-(i-1))]
      end
      for i=1,299 do --0 to 5 minutes back
         player_xp_arr[(300-(i-1))]=player_xp_arr[(300-i)]
         xpperminuteftotal=xpperminuteftotal+player_xp_arr[(300-(i-1))]
      end
      player_xp_arr[1]=me.xp-player_xp_lasttickxp
      xpperminuteftotal=xpperminuteftotal+player_xp_arr[1]
      xpperminutettotal=xpperminutettotal+xpperminuteftotal
      player_xp_p_fmin = math.floor(xpperminuteftotal/5)
      player_xp_p_tmin = math.floor(xpperminutettotal/10)
      player_xp_lasttickxp = me.xp
      player_lasttick=os.time()
   end
   

   --auxbox_prop_line("XP TNL:", player_xp_next_level)
   --auxbox_prop_line("XP/min (session):",string.format("%d(%d min)",player_xp_p_min,math.floor(player_xp_next_level/player_xp_p_min)))
   --auxbox_prop_line("XP/min (10 mins):",string.format("%d(%d)",player_xp_p_tmin,math.floor(player_xp_next_level/player_xp_p_tmin)))
   --auxbox_prop_line("XP/min (5 mins):",string.format("%d(%d)",player_xp_p_fmin,math.floor(player_xp_next_level/player_xp_p_fmin)))
   --auxbox_prop_line("Last XP gain:", player_lastxp)
   --auxbox_prop_line("Session time:", player_session_time)

end

function DPS_Calc()
   local dwmindmg, dwmaxdmg, dwavgdmg
   dwavgdmg = 0
   local weapons = 1

   --Should merge weap delay, stat dmg multiplier, total AS and AVG dmg.
   --auxbox_prop_line("Weapon Delay:", me:get_weapon_delay())
   --auxbox_prop_line("Stat DMG Multiplier:", me:stat_damage_multiplier())

   --Merge material dmg multiplier and weapon modifier into avg dmg.
   --auxbox_prop_line("mtrl dmg multi:", wl:get_material_dmg_mult(me.weapon,false))
   --auxbox_prop_line("weap modifier:", get_modifier(me.weapon))
   local offhand = wl:get_type(me.shield)
   --auxbox_prop_line(wl:get_speed(me.weapon),wl:get_speed(me.shield))

   if offhand == 87
   then
      dwmindmg = math.floor((wl:get_no_dice(me.shield)+get_modifier(me.shield))*wl:get_material_dmg_mult(me.shield,false))
      dwmaxdmg = math.floor(((wl:get_no_sides(me.shield)*wl:get_no_dice(me.shield))+get_modifier(me.shield))*wl:get_material_dmg_mult(me.shield,false))
      dwavgdmg = (dwmindmg+dwmaxdmg)/2
      weapons=2
   end

   local mindmg = math.floor((me:get_dmg_dice()+get_modifier(me.weapon))*wl:get_material_dmg_mult(me.weapon,false))
   local maxdmg = math.floor(((me:get_dmg_sides()*me:get_dmg_dice())+get_modifier(me.weapon))*wl:get_material_dmg_mult(me.weapon,false))
   local avgdmg = (mindmg+maxdmg)/2
   local wrating = 0
   --auxbox_prop_line("Mainhand AVG DMG:", avgdmg)
   --auxbox_prop_line("Offhand AVG DMG:", dwavgdmg)

   --equipped weapon(s) rating - first draft
   --seems to overvalue fast weapons and undervalue dual wield
   --local wrating = (((avgdmg+dwavgdmg)*me:stat_damage_multiplier())+me:get_thaco())*(1000/me:get_weapon_delay())

   --equipped weapon(s) rating - second draft
   --seems to better, now only to withdraw the weapon modifiers from thaco - or should I?
   --wrating = (((avgdmg+dwavgdmg)*me:stat_damage_multiplier())+(me:get_thaco()*weapons))*(1000/me:get_weapon_delay())

   --equipped weapon(s) rating - third draft
   --This now assumes that you're wielding your weapon in your weapon slot and then your shield slot.
   --Maybe I should do each weapon individually and then add them together?
   if weapons == 1 then
      wrating = (((avgdmg+dwavgdmg)*me:stat_damage_multiplier())+((me:get_thaco()-get_modifier(me.weapon))*weapons))*(1000/me:get_weapon_delay())
   else
      wrating = (((avgdmg+dwavgdmg)*me:stat_damage_multiplier())+((me:get_thaco()-get_modifier(me.weapon)-get_modifier(me.shield))*weapons))*(1000/me:get_weapon_delay())
   end

   --auxbox_prop_line("Weapon rating:", string.format("%0.f",wrating))
end

function Items_Left()
   auxbox_prop_line("    Potions:")
   auxbox_prop_line("Mega Yellow Potions:", items:get_qty_basecode(363))
   auxbox_prop_line("Greater Yellow Potions:", items:get_qty_basecode(260)) --matches with ALL yellow potions, should use make_code(260,0,15,3), leaving it for alts
   auxbox_prop_line("Mega Blue Potions:", items:get_qty_basecode(364))
   auxbox_prop_line("Blue Potions:", items:get_qty_basecode(261))
   auxbox_prop_line("Purple Potions:", items:get_qty_basecode(360))
   --auxbox_prop_line("Khaki Potions:", items:get_qty_basecode(380))
   --auxbox_prop_line("White Potions:", items:get_qty_basecode(354))
   --auxbox_prop_line("Cyan Potions:", items:get_qty_basecode(356))
   --auxbox_prop_line("Orange Potions:", items:get_qty_basecode(355))
   auxbox_prop_line("Brown Potions:", items:get_qty_basecode(358))
   auxbox_blank_line()
   --auxbox_prop_line("    Food:")
   auxbox_blank_line()
   auxbox_prop_line("    Scrolls:")
   --auxbox_prop_line("Scroll of Health:", items:get_qty_basecode(1298)) --should use make_code(1298,0,15,3)
   --auxbox_prop_line("Scroll of Protection:", items:get_qty_basecode(1297))
   --auxbox_prop_line("Scroll of Galvinising:",items:get_qty_basecode(1484))
   --auxbox_prop_line("Scroll - VL", items:get_qty(make_code(286,0,0,4))) --286
   auxbox_prop_line("Sanct Lor:", items:get_qty(make_code(286,0,0,18)))
   auxbox_prop_line("Kal Ort Por:", items:get_qty(make_code(286,0,0,13)))
   auxbox_prop_line("Town Portal:", items:get_qty_basecode(293))
   auxbox_prop_line("Greater Health:", items:get_qty_basecode(12))
   auxbox_blank_line()
   auxbox_prop_line("Soul Shards:", items:get_qty_basecode(1283))
   auxbox_prop_line("Omelettes:", items:get_qty_basecode(1380))
   auxbox_blank_line()
   --auxbox_prop_line("Scrolls of Uncurse:", items:get_qty_basecode(315))
   --auxbox_prop_line("Black Potions:", items:get_qty_basecode(352))
   --auxbox_prop_line(" \24Other:")
   --auxbox_prop_line("Bandages:", items:get_qty_basecode(375))
   --auxbox_prop_line("Wonderous Fish:", items:get_qty(make_code(279,7,0,0))) --279
   --auxbox_prop_line("Charred Blue Dragon", items:get_qty(make_code(1334,0xd,0x02,0x12)))
   --auxbox_prop_line("Superior Lava Fish", items:get_qty(make_code(279,4,15,4)))
   --auxbox_prop_line("Dragon Rations:", items:get_qty_basecode(1399))
   --auxbox_prop_line(" \24Coins:")
   --auxbox_blank_line()
   auxbox_prop_line("    Coins:")
   auxbox_prop_line("Adamantium coins:", items:get_qty(make_code(0x1000044f,0x0,0x0,0))) --make_code(0x1000044f,0x0,0x0,0) need to figure out the code for soulbound(?)
   auxbox_prop_line("Crystal coins:", items:get_qty(make_code(0x1000f5ca,0x0,0x0,0x0))) -- won't match because of it's soulbound(?)
   auxbox_prop_line("Glass coins:", items:get_qty(make_code(0x1000d5ca,0x0,0x0,0x0)))
   auxbox_prop_line("Silver Coins:", items:get_qty_basecode(1482))
end

-- explode(seperator, string)
-- from http://lua-users.org/wiki/SplitJoin
function explode(d,p)
  local t, ll
  t={}
  ll=0
  if(#p == 1) then return p end
    while true do
      l=string.find(p,d,ll+1,true) -- find the next d in the string
      if l~=nil then -- if "not not" found then..
        table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
        ll=l+1 -- save just after where we found it for searching next time.
      else
        table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
        break -- Break at end, as it should be, according to the lua manual.
      end
    end
  return t
end

-- Real World Time - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
function auxbox_time()

   auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
   
 
 
   if os.difftime(os.time(), sessionstart) > session_time then -- just to reduce the script to every second
 
    session_time = os.difftime(os.time(), sessionstart)
    session_d_float = session_time / 60 / 60 / 24
    session_d = math.floor(session_d_float)
    session_h = math.floor((session_d_float - session_d)*24)
    session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
    session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)
  end   
 
   if session_d~=nil then
     auxbox_prop_line("Session time:", string.format("%02.f:%02.f:%02.f:%02.f", session_d, session_h, session_m, session_s))   
   end
end


function auxbox_f5_message()
   auxbox_prop_line("Press Alt-F5 to Reset", "")
end

function auxbox_prop_line(prop_name, prop_val)
 
  local pvl=0
  if prop_name==nil then prop_name="" end
  if prop_val==nil then prop_val="" end
  local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
   auxbox_next_line = auxbox_next_line + 1
   d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
end

function auxbox_blank_line()
   auxbox_next_line = auxbox_next_line + 1
end

function auxbox_ability_binds()
   local cnt=0         
   for i=10,15 do
      if me.spell_binds[i]~=-1 then
      auxbox_prop_line(shiftkeys[i-9],spells:get_full_spell_name(me.spell_binds[i]))
      cnt=cnt+1
     end
  end
  return cnt
end

--- Damage Per Second -- original script provided by LordMortiferus
last_session_seconds = 0
last_5_dpst = { g_dpst, g_dpst, g_dpst, g_dpst, g_dpst }
last_5_dtpst = { g_dtpst, g_dtpst, g_dtpst, g_dtpst, g_dtpst }
last_dpst = g_dpst
recent_dmg = { 0, 0, 0, 0, 0 }

function auxbox_damage_per_second()
   local session_seconds = os.time() - sessionstart
   
   if session_seconds > last_session_seconds then
      last_session_seconds = session_seconds
      last_5_dpst[5] = last_5_dpst[4]
      last_5_dpst[4] = last_5_dpst[3]
      last_5_dpst[3] = last_5_dpst[2]
      last_5_dpst[2] = last_5_dpst[1]  
      last_5_dpst[1] = g_dpst

      last_5_dpst[5] = last_5_dpst[4]
      last_5_dpst[4] = last_5_dpst[3]
      last_5_dpst[3] = last_5_dpst[2]
      last_5_dpst[2] = last_5_dpst[1]  
      last_5_dpst[1] = g_dtpst   
   end
   
   if last_dpst ~= g_dpst then
      recent_dmg[5] = recent_dmg[4]
      recent_dmg[4] = recent_dmg[3]
      recent_dmg[3] = recent_dmg[2]
      recent_dmg[2] = recent_dmg[1]
      recent_dmg[1] = g_dpst - last_dpst
      last_dpst = g_dpst
   end
   
   --auxbox_prop_line("Dmg Dealt / Sec", string.format("%d", (last_5_dpst[1] - last_5_dpst[4])  / 4
   --auxbox_prop_line("Dmg Taken / Sec", string.format("%d", (last_5_dtpst[1] - last_5_dtpst[4])  / 4)
   auxbox_prop_line("Last 5 Hits:", "")
   auxbox_prop_line("", string.format("%d  %d  %d  %d  %d", recent_dmg[5],recent_dmg[4], recent_dmg[3], recent_dmg[2], recent_dmg[1]))
end
Rikimaru

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

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

Re: Custom Auxbox Creations

Post by Keighn » Wed May 08, 2013 6:18 am

Small note: Before each auxbox coding be sure to describe what the box does: ie.
Displays:
Real time
# of Mega Yellows in inventory
# of greater health scrolls in inventory
Last five hits (damage)
etc.

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

Re: Custom Auxbox Creations

Post by CIAassassin » Wed May 08, 2013 6:20 am

This is the code I use, It's a streamline of Severians code (removed a few lines and the monk status)

Code: Select all

    session_start = os.time() - 1
    auxbox_next_line = 0

    function auxbox()
       d:auxbox_clear();
       auxbox_next_line = 0
       auxbox_real_world_time()
       auxbox_blank_line()
       auxbox_damage_per_second()
       auxbox_xp()
    end

    function auxbox_prop_line(prop_name, prop_val)
       local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
       auxbox_next_line = auxbox_next_line + 1
       d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
    end

    function auxbox_blank_line()
       auxbox_next_line = auxbox_next_line + 1
    end

    function auxbox_real_world_time()
       auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
    end


    -- Damage Per Second (by Severian)
    -- starts displaying DPS after 35 hits, and gets more accurate the more hits you make
    -- assumes few intervals walking and more intervals between continuous hits

    VERBOSE_DPS_REPORT = true
    last_dpst = g_dpst
    hits_recorded = 0
    dmg_log = {}
    median_damage = -1
    recent_hit_times = {}
    five_hit_intervals = {}
    median_interval = -1

    function auxbox_damage_per_second()
       local current_time
       local current_dmg
       local current_five_hit_interval
       local temp_var
       local temp_five_hit_intervals
       local temp_dmg_log
       if last_dpst ~= g_dpst then
          current_time = os.time()
          current_dmg = g_dpst - last_dpst
          hits_recorded = hits_recorded + 1
          if hits_recorded <= 30 then -- first 30 hits
             table.insert(dmg_log, 1, current_dmg)
          else -- on and after the 31st hit
             table.remove(dmg_log, 30)
             table.insert(dmg_log, 1, current_dmg)
          end
          last_dpst = g_dpst
          if hits_recorded < 6 then -- first 5 hits
             table.insert(recent_hit_times, 1, current_time)
          else -- on and after the 6th hit
             table.remove(recent_hit_times, 5)
             table.insert(recent_hit_times, 1, current_time)
          end
          if hits_recorded >= 5 then
             current_five_hit_interval = recent_hit_times[1] - recent_hit_times[5]
             if hits_recorded <= 35 then -- first 30 "5 hit" intervals
                table.insert(five_hit_intervals, 1, current_five_hit_interval)
             else -- on and after the 31st "5 hit" interval
                table.remove(five_hit_intervals, 30)
                table.insert(five_hit_intervals, 1, current_five_hit_interval)
             end
          end
       end
       if hits_recorded < 35 then
          temp_var = 35 - hits_recorded
          auxbox_prop_line("DPS:", string.format("...in %d hits...", temp_var))
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Median Damage:", "") end
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Median 5-Hit Time:", "") end
       else
          temp_dmg_log = {}
          for i,v in pairs(dmg_log) do
             temp_dmg_log[i] = v
          end
          table.sort(temp_dmg_log)
          temp_five_hit_intervals = {}
          for i,v in pairs(five_hit_intervals) do
             temp_five_hit_intervals[i] = v
          end
          table.sort(temp_five_hit_intervals)
          median_damage = math.ceil((temp_dmg_log[15] + temp_dmg_log[16]) / 2)
          median_interval = math.floor((temp_five_hit_intervals[15] + temp_five_hit_intervals[16]) / 2)
          temp_var = math.floor((median_damage * 5) / median_interval)
          auxbox_prop_line("DPS:", string.format("%d", temp_var))
          if VERBOSE_DPS_REPORT then
             auxbox_prop_line("Median Damage:", string.format("%d", median_damage))
          end
          if VERBOSE_DPS_REPORT then
             auxbox_prop_line("Median 5-Hit Time:", string.format("%d", median_interval))
          end
       end
    end

    session_start_xp = me.xp -- var to calculate xp gain per session
    session_start_age = me.age -- var to calculate time played per session
    session_time = 0
    current_level = 0

    -- beginning of XP-array
    req_xp = {}
    req_xp[1] = 0 -- fixed XP value
    req_xp[2] = 200 -- fixed XP value
    req_xp[26] = 93000 -- fixed XP value

    for i=3,25 do -- adds XP for lvl 3 to 25 to array
      req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
    end

    for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
      req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
    end

    if me.xp >= req_xp[1000] then
       current_level = 1000
    else
       for i = 1,999 do -- getting current player level based on array
          if req_xp[i] <= me.xp
          and req_xp[i + 1] > me.xp
          then
             current_level = i
             break
          end
       end
    end

    -- end of XP-array

    function auxbox_xp()
       if current_level <= 1000 then
          local xptolvl_float = ((me.xp - req_xp[current_level]))/(req_xp[current_level+1]-req_xp[current_level]) -- % needed for next level
          local lvl_float = current_level + me.remort_level * 75 + xptolvl_float -- combines actual lvl with the % needed for next lvl

           -- checks if player leveled or remorted
          if xptolvl_float >= 1 or xptolvl_float < 0 then
             for i = 1,999 do
                if req_xp[i] <= me.xp
                and req_xp[i + 1] > me.xp
                then
                   current_level = i
                   break
                end
             end
          end
          
          if os.difftime(os.time(), session_start) > session_time then -- just to reduce the script to every second
             session_time = os.difftime(os.time(), session_start)
             session_d_float = session_time / 60 / 60 / 24
             session_d = math.floor(session_d_float)
             session_h = math.floor((session_d_float - session_d)*24)
             session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
             session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)

             xpgain = me.xp - session_start_xp 
             xps = xpgain/session_time

             if me.age-session_start_age > 0  then
               xpmin = xpgain/(me.age-session_start_age)
             else
               xpmin = 0
             end

             xptolvl = req_xp[current_level + 1] - me.xp
             xpto1k = req_xp[1000] - me.xp

             if xps > 0 then
               timetolvl = xptolvl / xps
               timeto1k = xpto1k / xps
             else
               timetolvl = 0
               timeto1k = 0
             end

             timetolvl_d_float = timetolvl / 60 / 60 / 24
             timetolvl_d = math.floor(timetolvl_d_float)
             timetolvl_h = math.floor((timetolvl_d_float - timetolvl_d)*24)
             timetolvl_m = math.floor(((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60)
             timetolvl_s = math.floor((((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60 - timetolvl_m) * 60)

             timeto1k_d_float = timeto1k / 60 / 60 / 24
             timeto1k_d = math.floor(timeto1k_d_float)
             timeto1k_h = math.floor((timeto1k_d_float - timeto1k_d)*24)
             timeto1k_m = math.floor(((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60)
             timeto1k_s = math.floor((((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60 - timeto1k_m) * 60)
          end
             auxbox_prop_line("XP to Level:", string.format("%d", xptolvl))
             auxbox_prop_line("XP per Minute:" ,string.format("%d", xpmin))
             auxbox_prop_line("Time to Level:" ,string.format("%02.f:%02.f:%02.f:%02.f", timetolvl_d, timetolvl_h, timetolvl_m, timetolvl_s))
       end
    end
Last edited by CIAassassin on Wed May 08, 2013 6:45 am, edited 1 time in total.
Rikimaru

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

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

Re: Custom Auxbox Creations

Post by CIAassassin » Wed May 08, 2013 6:26 am

Keighn wrote:Small note: Before each auxbox coding be sure to describe what the box does: ie.
Displays:
Real time
# of Mega Yellows in inventory
# of greater health scrolls in inventory
Last five hits (damage)
etc.

all of the functions list what they do after auxbox: ex, function auxbox_damage_per_second. Now the item counters, that Im not sure about. havent played with them yet. Im about to though.
Rikimaru

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

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

Re: Custom Auxbox Creations

Post by Keighn » Wed May 08, 2013 6:33 am

Well, mostly I posted that for future box makers so we know if we want to use theirs or not. I have some ideas though for when you just want to plug in a box for a specific task. It would be cool if we could change the auxbox's while ingame though. Some sort of command perhaps:

/auxbox or auxbox1 (sets it to default)
/auxbox2 the 2nd on if it is labeled aux2
/auxbox3 etc....

Crafting Box: (logger/miner)
Displays:
Logs of each tint
Ores of each tint
Ingots of each tint
gold nuggets
blackrock
something else

Crafting Box: (alchemist)
potions
ingredients for potions

Class orientated versions (one for warrior, rogue, mage, cleric, monk)

Timekeeper
IRL TIme
Sydney time
How long alt has existed
How long you've been on
EUO time (that's what a pocket watch is for but hey)

etc.

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

Re: Custom Auxbox Creations

Post by Keighn » Wed May 08, 2013 6:47 am

Notepad++ is free and helpful.

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

Re: Custom Auxbox Creations

Post by CIAassassin » Wed May 08, 2013 6:53 am

heard.

OK, so lets get working on this: Keighn has asked to get a new code that shows dps and the last five hits in the same window. Ive tried to get it to work, but have come into a complication. I can get one or the other to work in one auxbox, but not both. Ive tried to rename duplicate callers, as well as tried to hack the two together which resulted in only the first one running. It also totally buggers the XP clock. I need help with getting both the DPS meter, last five, and xp clock working together. Anyone want to take a stab at it?

using this:

Code: Select all

--- Damage Per Second -- original script provided by LordMortiferus
last_session_seconds = 0
last_5_dpst = { g_dpst, g_dpst, g_dpst, g_dpst, g_dpst }
last_5_dtpst = { g_dtpst, g_dtpst, g_dtpst, g_dtpst, g_dtpst }
last_dpst = g_dpst
recent_dmg = { 0, 0, 0, 0, 0 }

function auxbox_damage_per_second()
   local session_seconds = os.time() - sessionstart
   
   if session_seconds > last_session_seconds then
      last_session_seconds = session_seconds
      last_5_dpst[5] = last_5_dpst[4]
      last_5_dpst[4] = last_5_dpst[3]
      last_5_dpst[3] = last_5_dpst[2]
      last_5_dpst[2] = last_5_dpst[1] 
      last_5_dpst[1] = g_dpst

      last_5_dpst[5] = last_5_dpst[4]
      last_5_dpst[4] = last_5_dpst[3]
      last_5_dpst[3] = last_5_dpst[2]
      last_5_dpst[2] = last_5_dpst[1] 
      last_5_dpst[1] = g_dtpst   
   end
   
   if last_dpst ~= g_dpst then
      recent_dmg[5] = recent_dmg[4]
      recent_dmg[4] = recent_dmg[3]
      recent_dmg[3] = recent_dmg[2]
      recent_dmg[2] = recent_dmg[1]
      recent_dmg[1] = g_dpst - last_dpst
      last_dpst = g_dpst
   end
   
   auxbox_prop_line("Last 5 Hits:", "")
   auxbox_prop_line("", string.format("%d  %d  %d  %d  %d", recent_dmg[5],recent_dmg[4], recent_dmg[3], recent_dmg[2], recent_dmg[1]))
end
and this:

Code: Select all

    session_start = os.time() - 1
    auxbox_next_line = 0

    function auxbox()
      d:auxbox_clear();
      auxbox_next_line = 0
      auxbox_real_world_time()
	  auxbox_blank_line()
	  auxbox_damage_per_second()
      auxbox_xp()
    end

    function auxbox_prop_line(prop_name, prop_val)
      local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
      auxbox_next_line = auxbox_next_line + 1
      d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
    end

    function auxbox_blank_line()
      auxbox_next_line = auxbox_next_line + 1
    end

    function auxbox_real_world_time()
      auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
    end


    -- Damage Per Second (by Severian)
    -- starts displaying DPS after 35 hits, and gets more accurate the more hits you make
    -- assumes few intervals walking and more intervals between continuous hits

    VERBOSE_DPS_REPORT = true
    last_dpst = g_dpst
    hits_recorded = 0
    dmg_log = {}
    median_damage = -1
    recent_hit_times = {}
    five_hit_intervals = {}
    median_interval = -1

    function auxbox_damage_per_second()
      local current_time
      local current_dmg
      local current_five_hit_interval
      local temp_var
      local temp_five_hit_intervals
      local temp_dmg_log
        if last_dpst ~= g_dpst then
          current_time = os.time()
          current_dmg = g_dpst - last_dpst
          hits_recorded = hits_recorded + 1
            if hits_recorded <= 30 then -- first 30 hits
              table.insert(dmg_log, 1, current_dmg)
            else -- on and after the 31st hit
              table.remove(dmg_log, 30)
              table.insert(dmg_log, 1, current_dmg)
            end
          
		  last_dpst = g_dpst
            if hits_recorded < 6 then -- first 5 hits
              table.insert(recent_hit_times, 1, current_time)
            else -- on and after the 6th hit
              table.remove(recent_hit_times, 5)
              table.insert(recent_hit_times, 1, current_time)
            end
          
		    if hits_recorded >= 5 then
              current_five_hit_interval = recent_hit_times[1] - recent_hit_times[5]
                if hits_recorded <= 35 then -- first 30 "5 hit" intervals
                  table.insert(five_hit_intervals, 1, current_five_hit_interval)
                else -- on and after the 31st "5 hit" interval
                  table.remove(five_hit_intervals, 30)
                  table.insert(five_hit_intervals, 1, current_five_hit_interval)
                end
            end
        end
        
		if hits_recorded < 35 then
          temp_var = 35 - hits_recorded
          auxbox_prop_line("DPS:", string.format("...in %d hits...", temp_var))
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Median Damage:", "") end
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Median 5-Hit Time:", "") end
        else
          temp_dmg_log = {}
            for i,v in pairs(dmg_log) do
              temp_dmg_log[i] = v
            end
          
		  table.sort(temp_dmg_log)
          temp_five_hit_intervals = {}
            for i,v in pairs(five_hit_intervals) do
              temp_five_hit_intervals[i] = v
            end
          
		  table.sort(temp_five_hit_intervals)
          median_damage = math.ceil((temp_dmg_log[15] + temp_dmg_log[16]) / 2)
          median_interval = math.floor((temp_five_hit_intervals[15] + temp_five_hit_intervals[16]) / 2)
          temp_var = math.floor((median_damage * 5) / median_interval)
          auxbox_prop_line("DPS:", string.format("%d", temp_var))
            if VERBOSE_DPS_REPORT then
              auxbox_prop_line("Median Damage:", string.format("%d", median_damage))
            end
            if VERBOSE_DPS_REPORT then
              auxbox_prop_line("Median 5-Hit Time:", string.format("%d", median_interval))
            end
        end
    end

    session_start_xp = me.xp -- var to calculate xp gain per session
    session_start_age = me.age -- var to calculate time played per session
    session_time = 0
    current_level = 0

    -- beginning of XP-array
    req_xp = {}
    req_xp[1] = 0 -- fixed XP value
    req_xp[2] = 200 -- fixed XP value
    req_xp[26] = 93000 -- fixed XP value

    for i=3,25 do -- adds XP for lvl 3 to 25 to array
      req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
    end

    for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
      req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
    end

    if me.xp >= req_xp[1000] then
      current_level = 1000
    else
        for i = 1,999 do -- getting current player level based on array
            if req_xp[i] <= me.xp
             and req_xp[i + 1] > me.xp
            then
              current_level = i
              break
            end
        end
    end

    -- end of XP-array

    function auxbox_xp()
        if current_level <= 1000 then
          local xptolvl_float = ((me.xp - req_xp[current_level]))/(req_xp[current_level+1]-req_xp[current_level]) -- % needed for next level
          local lvl_float = current_level + me.remort_level * 75 + xptolvl_float -- combines actual lvl with the % needed for next lvl

          -- checks if player leveled or remorted
            if xptolvl_float >= 1 or xptolvl_float < 0 then
              for i = 1,999 do
                if req_xp[i] <= me.xp
                 and req_xp[i + 1] > me.xp
                then
                  current_level = i
                  break
                end
            end
        end
          
        if os.difftime(os.time(), session_start) > session_time then -- just to reduce the script to every second
          session_time = os.difftime(os.time(), session_start)
          session_d_float = session_time / 60 / 60 / 24
          session_d = math.floor(session_d_float)
          session_h = math.floor((session_d_float - session_d)*24)
          session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
          session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)

          xpgain = me.xp - session_start_xp 
          xps = xpgain/session_time

            if me.age-session_start_age > 0  then
              xpmin = xpgain/(me.age-session_start_age)
            else
              xpmin = 0
            end

          xptolvl = req_xp[current_level + 1] - me.xp
          xpto1k = req_xp[1000] - me.xp

            if xps > 0 then
              timetolvl = xptolvl / xps
              timeto1k = xpto1k / xps
            else
              timetolvl = 0
              timeto1k = 0
            end

          timetolvl_d_float = timetolvl / 60 / 60 / 24
          timetolvl_d = math.floor(timetolvl_d_float)
          timetolvl_h = math.floor((timetolvl_d_float - timetolvl_d)*24)
          timetolvl_m = math.floor(((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60)
          timetolvl_s = math.floor((((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60 - timetolvl_m) * 60)

          timeto1k_d_float = timeto1k / 60 / 60 / 24
          timeto1k_d = math.floor(timeto1k_d_float)
          timeto1k_h = math.floor((timeto1k_d_float - timeto1k_d)*24)
          timeto1k_m = math.floor(((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60)
          timeto1k_s = math.floor((((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60 - timeto1k_m) * 60)
        end
          auxbox_prop_line("XP to Level:", string.format("%d", xptolvl))
          auxbox_prop_line("XP per Minute:" ,string.format("%d", xpmin))
          auxbox_prop_line("Time to Level:" ,string.format("%02.f:%02.f:%02.f:%02.f", timetolvl_d, timetolvl_h, timetolvl_m, timetolvl_s))
    end
end
Rikimaru

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

Sweetie
I'll be going back to Tibia next week.
Posts: 29
Joined: Sun Mar 31, 2013 12:38 pm

Re: Custom Auxbox Creations

Post by Sweetie » Wed May 08, 2013 7:01 am

i like this one, sweet and to the point.. it's someone elses (I forget who) but I just cut out parts to make it what I wanted.

Code: Select all

Real World Time
Moon Phase


Level
Current XP
Before Level
XP/s
XP/m

alt-f message
forums
website
Image

Code: Select all

session_start = os.time() - 1
auxbox_next_line = 0

function auxbox()
	
	d:auxbox_clear();
	auxbox_next_line = 0 
		
	auxbox_real_world_time()	
	auxbox_moon_info()	
	auxbox_blank_line()
		
	--auxbox_damage_per_second()
	--auxbox_blank_line()
	
	auxbox_xp()
    auxbox_blank_line()	
	
	--update_skill_experience()
	--auxbox_all_skill_levels()
	--auxbox_class_skill_levels()	
	--auxbox_recent_crafting_skill_levels()
	--auxbox_recent_skill_levels()	
	--auxbox_blank_line()
	
	auxbox_f5_message()
	forums_message()
	website_message()	
end

function auxbox_prop_line(prop_name, prop_val)
    local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
	auxbox_next_line = auxbox_next_line + 1
	d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
end

function auxbox_blank_line()
	auxbox_next_line = auxbox_next_line + 1
end



-- Real World Time - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
function auxbox_real_world_time()
	auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
end



-- Moon Info - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
function auxbox_moon_info()
	if world_time < 9 * 60 -- if its night time
	or world_time > 21 * 60 
	then
		auxbox_prop_line("Moon Phase:", string.format("%d", moon_phase))
		-- if moon_phase = full and is_night = true say "FULL MOON"
		-- if moon_phase = new ... "New Moon"
	end
	if world_time < 60 then -- between 12am and 1am
		auxbox_prop_line("ITS MIDNIGHT", "(*)")
	end
end



-- Equipment Summary  - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
function auxbox_current_equipment()
    auxbox_prop_line("---- Current Equipment -----", "")
	auxbox_prop_line(wl:get_full_name(me.weapon), "")
	--auxbox_prop_line("  Damage", string.format("%dd%d", me:get_dmg_dice(), me:get_dmg_sides()))
	auxbox_prop_line(wl:get_full_name(me.shield), "")
	auxbox_prop_line(wl:get_full_name(me.hat), "")
	auxbox_prop_line(wl:get_full_name(me.armour), "")
	auxbox_prop_line(wl:get_full_name(me.gloves), "")
	auxbox_prop_line(wl:get_full_name(me.trousers), "")
	auxbox_prop_line(wl:get_full_name(me.boots), "")
	auxbox_prop_line(wl:get_full_name(me.ring1), "")
	auxbox_prop_line(wl:get_full_name(me.ring2), "")
	auxbox_prop_line(wl:get_full_name(me.amulet), "")
	auxbox_prop_line(wl:get_full_name(me.sigil1), "")
	auxbox_prop_line(wl:get_full_name(me.sigil2), "")
	auxbox_prop_line(wl:get_full_name(me.sigil3), "")
end



-- Skill level stuff - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
skill_count = 40 

auxbox_class_skills = 
{	0, 1, 2, 3, 26 --fighter
,	17, 18, 13, 14, 15, 9	--thief
,	7, 33 -- mage
,	34, 38, 36  -- priest
,   10, 40 -- monk
}

auxbox_crafting_skills = 
{	4
,   5
, 	6
,	8
,	11
,	12
,	16
,   19
,	20
,	21, 22, 23, 24, 25
,	27, 28
,	29
,	30
,	31, 32
,	35, 37
,	39
}

auxbox_prev_skill_values = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
auxbox_skill_last_updated = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
auxbox_prev_skill_values[0] = -1
auxbox_skill_last_updated[0] = -1

auxbox_skill_names = 
{ 	"polearms" -- 1
,	"maces" -- 2
,	"tactics" -- 3
,	"woodcrafting" --4
,	"mining" -- 5
,	"weaponsmith" -- 6
,	"magery" -- 7
,	"fishing" -- 8
,	"locks" --9
,	"unarmed" --10
,	"meditation" -- 11
,	"alchemy" --12
,	"ranged" --13
,	"stealth" --14
,	"traps" --15
,	"item lore" --16
,	"shortswords" --17
,	"foils" -- 18
,	"Skill 19"
,	"tailoring" --20
,	"tinkering" -- 21
,	"Skill 22"
,	"Skill 23"
,	"Skill 24"
,	"Skill 25"
,	"block" --26
,	"cartography" --27
,	"healing" --28
,	"enchanting"  --29
,	"armourer" -- 30
,	"inscription" --31
,	"taming" --32
,	"sorcery" --33
,	"piety" --34
,	"Skill 35"
,	"blessed maces" --36
,	"staves" -- 37
,	"divinity" --38
,	"cooking" --39
,	"sanctity" --40
}
auxbox_skill_names[0] = "longswords"

function auxbox_skill_line(skill_index)
	if me:get_skill(skill_index) > 0 then
		auxbox_prop_line(auxbox_skill_names[skill_index], string.format("%f%%", me:get_skill(skill_index)))
	end	
end

-- I used this for debugging, its pretty similar to the skill tab, so kind of pointless, but why delete it, now that it works
function auxbox_all_skill_levels()
	for i = 0, skill_count do
		auxbox_skill_line(i)
	end
end

-- shows level for all of your class related skills 
-- regardless of how long it has been since you got experience in that skill
function auxbox_class_skill_levels()
	for i = 1, #auxbox_class_skills do
		auxbox_skill_line(auxbox_class_skills[i])
	end
end

-- you have to call this before either of the two functions below it or they wont know what has recently changed
function update_skill_experience()
	for i = 0, skill_count do
		if auxbox_prev_skill_values[i] < me:get_skill(i) then
			auxbox_skill_last_updated[i] = auxboxcnt
			auxbox_prev_skill_values[i] = me:get_skill(i)
		end
	end
end

-- shows level of any skill that has recently received experience
-- you should really either use THIS or auxbox_class_skill_levels + auxbox_recent_craft_skill_levels
-- the advantage of this function is that it doesnt show class skills if you arent currently working on them (saves space)
function auxbox_recent_skill_levels()
	for i = 0, skill_count do
		if auxbox_skill_last_updated[i] > auxboxcnt - 300 
		and auxbox_skill_last_updated[i] > 1
		then
			auxbox_skill_line(i)
		end
	end
end

-- shows level of any non-class skill that has recently received experience
function auxbox_recent_crafting_skill_levels()
	for i = 1, #auxbox_crafting_skills do
		if auxbox_skill_last_updated[auxbox_crafting_skills[i]] > auxboxcnt - 300 
		and auxbox_skill_last_updated[auxbox_crafting_skills[i]] > 1
		then
			auxbox_skill_line(auxbox_crafting_skills[i])
		end
	end
end




-- Bound Item Quantities  - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
function auxbox_bound_item_qtys()
	local item
	local name
	for i = 1, 50 do	
		item = me.item_binds[i]
		name = wl:get_full_name(item)
		
		if item 
		and not wl:is_tool(item)
		and name ~= "NOTHING" 
		then		
			auxbox_prop_line(name, items:get_qty(item))
		end
	end
end



--- Damage Per Second -- original script proveded by LordMortiferus
last_session_seconds = 0
last_4_dpst = { g_dpst, g_dpst, g_dpst, g_dpst }
last_4_dtpst = { g_dtpst, g_dtpst, g_dtpst, g_dtpst }
last_dpst = g_dpst
recent_dmg = { 0, 0, 0, 0 }

function auxbox_damage_per_second() 
	local session_seconds = os.time() - session_start
	
	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] = 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] = g_dtpst	
	end
	
	if last_dpst ~= g_dpst then
		recent_dmg[4] = recent_dmg[3]
		recent_dmg[3] = recent_dmg[2]
		recent_dmg[2] = recent_dmg[1]
		recent_dmg[1] = g_dpst - last_dpst
		last_dpst = g_dpst
	end
	
	auxbox_prop_line("Dmg Dealt / Sec", string.format("%d", (last_4_dpst[1] - last_4_dpst[4])  / 4))
	auxbox_prop_line("Dmg Taken / Sec", string.format("%d", (last_4_dtpst[1] - last_4_dtpst[4])  / 4))
	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

function auxbox_f5_message()
	auxbox_prop_line("Press alt-F5 to Reset", "")
end

function forums_message()
	auxbox_prop_line("http://forums.swut.net", "")
end

function website_message()
	auxbox_prop_line("http://www.euotopia.com", "")
end

-- XP by LordMortiferus 2013/01/28, rehashed by Brentoboy

session_start_xp = me.xp -- var to calculate xp gain per session
session_start_age = me.age -- var to calculate time played per session
session_time = 0
current_level = 0

-- beginning of XP-array
req_xp = {}
req_xp[1] = 0 -- fixed XP value
req_xp[2] = 200 -- fixed XP value
req_xp[26] = 93000 -- fixed XP value

for i=3,25 do -- adds XP for lvl 3 to 25 to array
  req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
end

for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
  req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
end

if me.xp >= req_xp[1000] then
	current_level = 1000
else
	for i = 1,999 do -- getting current player level based on array 
		if req_xp[i] <= me.xp 
		and req_xp[i + 1] > me.xp 
		then
			current_level = i
			break
		end
	end
end

-- end of XP-array

function auxbox_xp()
	if current_level <= 1000 then
		local xptolvl_float = ((me.xp - req_xp[current_level]))/(req_xp[current_level+1]-req_xp[current_level]) -- % needed for next level
		local lvl_float = current_level + me.remort_level * 75 + xptolvl_float -- combines actual lvl with the % needed for next lvl

		 -- checks if player leveled or remorted
		if xptolvl_float >= 1 or xptolvl_float < 0 then
			for i = 1,999 do
				if req_xp[i] <= me.xp 
				and req_xp[i + 1] > me.xp 
				then
					current_level = i
					break
				end
			end
		end
		
		if os.difftime(os.time(), session_start) > session_time then -- just to reduce the script to every second
			session_time = os.difftime(os.time(), session_start)
			session_d_float = session_time / 60 / 60 / 24
			session_d = math.floor(session_d_float)
			session_h = math.floor((session_d_float - session_d)*24)
			session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
			session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)

			xpgain = me.xp - session_start_xp  
			xps = xpgain/session_time

			if me.age-session_start_age > 0  then
			  xpmin = xpgain/(me.age-session_start_age)
			else 
			  xpmin = 0
			end

			xptolvl = req_xp[current_level + 1] - me.xp
			xpto1k = req_xp[1000] - me.xp

			if xps > 0 then
			  timetolvl = xptolvl / xps 
			  timeto1k = xpto1k / xps
			else 
			  timetolvl = 0
			  timeto1k = 0
			end

			timetolvl_d_float = timetolvl / 60 / 60 / 24
			timetolvl_d = math.floor(timetolvl_d_float)
			timetolvl_h = math.floor((timetolvl_d_float - timetolvl_d)*24)
			timetolvl_m = math.floor(((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60)
			timetolvl_s = math.floor((((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60 - timetolvl_m) * 60)

			timeto1k_d_float = timeto1k / 60 / 60 / 24
			timeto1k_d = math.floor(timeto1k_d_float)
			timeto1k_h = math.floor((timeto1k_d_float - timeto1k_d)*24)
			timeto1k_m = math.floor(((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60)
			timeto1k_s = math.floor((((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60 - timeto1k_m) * 60)
		end
		
		
		auxbox_prop_line("Level" ,string.format("%f",lvl_float))
		--auxbox_prop_line("Time" ,string.format("%02.f:%02.f:%02.f:%02.f", session_d, session_h, session_m, session_s))
  
		auxbox_prop_line("Current XP", string.format("%d", me.xp))
		auxbox_prop_line("Before Level", string.format("%d", xptolvl))
		auxbox_prop_line("XP/s" ,string.format("%d", xps))
		auxbox_prop_line("XP/min" ,string.format("%d", xpmin))
  
	end
end


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

Re: Custom Auxbox Creations

Post by CIAassassin » Wed May 08, 2013 9:07 am

Well this is where Im at after tinkering around with it for the last 5 hours or so. Im trying to splice in LordMs 5 hit counter into the median dmg time slot of Sevs DPS code without undoing the math needed to calculate the DPS, however it's not wanting to cooperate with me. I got the five hit counter to work, but the actual DPS measure isnt working now. Im still basically dealing with only one function working at a time. XP/min and to level timer are no longer working now either.
Arrows_Bullets.png

Code: Select all

    function auxbox()
	  session_start = os.time() - 1
      d:auxbox_clear();
	  auxbox_next_line = 0
      auxbox_real_world_time()
	  auxbox_blank_line()
	  auxbox_damage_per_second()
      auxbox_xp()
	  Items_Left()
    end

    function auxbox_prop_line(prop_name, prop_val)
      local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
      auxbox_next_line = auxbox_next_line + 1
      d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
    end

    function auxbox_blank_line()
      auxbox_next_line = auxbox_next_line + 1
    end

    function auxbox_real_world_time()
      auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
    end


    -- Damage Per Second (by Severian)
    -- starts displaying DPS after 35 hits, and gets more accurate the more hits you make
    -- assumes few intervals walking and more intervals between continuous hits

    VERBOSE_DPS_REPORT = true
    last_dpst = g_dpst
    hits_recorded = 0
    dmg_log = {}
    median_damage = -1
    recent_hit_times = {}
    five_hit_intervals = {}
    median_interval = -1
	recent_dmg = { 0, 0, 0, 0, 0 }
	last_5_dpst = { g_dpst, g_dpst, g_dpst, g_dpst, g_dpst }
    last_5_dtpst = { g_dtpst, g_dtpst, g_dtpst, g_dtpst, g_dtpst }
	last_session_seconds = 0

    function auxbox_damage_per_second()
      local current_time
      local current_dmg
      local current_five_hit_interval
      local temp_var
      local temp_five_hit_intervals
      local temp_dmg_log
	  local session_seconds = os.time() - session_start
        
		if session_seconds > last_session_seconds then
          last_session_seconds = session_seconds
          last_5_dpst[5] = last_5_dpst[4]
          last_5_dpst[4] = last_5_dpst[3]
          last_5_dpst[3] = last_5_dpst[2]
          last_5_dpst[2] = last_5_dpst[1]  
          last_5_dpst[1] = g_dpst
		  
          last_5_dpst[5] = last_5_dpst[4]
          last_5_dpst[4] = last_5_dpst[3]
          last_5_dpst[3] = last_5_dpst[2]
          last_5_dpst[2] = last_5_dpst[1]  
          last_5_dpst[1] = g_dtpst   
        end
   
        if last_dpst ~= g_dpst then
          recent_dmg[5] = recent_dmg[4]
          recent_dmg[4] = recent_dmg[3]
          recent_dmg[3] = recent_dmg[2]
          recent_dmg[2] = recent_dmg[1]           
		  recent_dmg[1] = g_dpst - last_dpst
          last_dpst = g_dpst
        end
		
		if last_dpst ~= g_dpst then
          current_time = os.time()
          current_dmg = g_dpst - last_dpst
          hits_recorded = hits_recorded + 1
            if hits_recorded <= 30 then -- first 30 hits
              table.insert(dmg_log, 1, current_dmg)
            else -- on and after the 31st hit
              table.remove(dmg_log, 30)
              table.insert(dmg_log, 1, current_dmg)
            end
          
		  last_dpst = g_dpst
            if hits_recorded < 6 then -- first 5 hits
              table.insert(recent_hit_times, 1, current_time)
            else -- on and after the 6th hit
              table.remove(recent_hit_times, 5)
              table.insert(recent_hit_times, 1, current_time)
            end
          
		    if hits_recorded >= 5 then
              current_five_hit_interval = recent_hit_times[1] - recent_hit_times[5]
                if hits_recorded <= 35 then -- first 30 "5 hit" intervals
                  table.insert(five_hit_intervals, 1, current_five_hit_interval)
                else -- on and after the 31st "5 hit" interval
                  table.remove(five_hit_intervals, 30)
                  table.insert(five_hit_intervals, 1, current_five_hit_interval)
                end
            end
        end
        
		if hits_recorded < 35 then
          temp_var = 35 - hits_recorded
          auxbox_prop_line("DPS:", string.format("...in %d hits...", temp_var))
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Median Damage:", "") end
          if VERBOSE_DPS_REPORT then auxbox_prop_line("Last Few Hits:", string.format("%d  %d  %d  %d  %d", recent_dmg[5],recent_dmg[4], recent_dmg[3], recent_dmg[2], recent_dmg[1]))end
        else
          temp_dmg_log = {}
            for i,v in pairs(dmg_log) do
              temp_dmg_log[i] = v
            end
          
		  table.sort(temp_dmg_log)
          temp_five_hit_intervals = {}
            for i,v in pairs(five_hit_intervals) do
              temp_five_hit_intervals[i] = v
            end
          
		  table.sort(temp_five_hit_intervals)
          median_damage = math.ceil((temp_dmg_log[15] + temp_dmg_log[16]) / 2)
          median_interval = math.floor((temp_five_hit_intervals[15] + temp_five_hit_intervals[16]) / 2)
          temp_var = math.floor((median_damage * 5) / median_interval)
          auxbox_prop_line("DPS:", string.format("%d", temp_var))
            if VERBOSE_DPS_REPORT then
              auxbox_prop_line("Median Damage:", string.format("%d", median_damage))
            end
            if VERBOSE_DPS_REPORT then
              auxbox_prop_line("Last Few Hits:", string.format("%d  %d  %d  %d  %d", recent_dmg[5],recent_dmg[4], recent_dmg[3], recent_dmg[2], recent_dmg[1]))
            end
        end
    end

    session_start_xp = me.xp -- var to calculate xp gain per session
    session_start_age = me.age -- var to calculate time played per session
    session_time = 0
    current_level = 0

    -- beginning of XP-array
    req_xp = {}
    req_xp[1] = 0 -- fixed XP value
    req_xp[2] = 200 -- fixed XP value
    req_xp[26] = 93000 -- fixed XP value

    for i=3,25 do -- adds XP for lvl 3 to 25 to array
      req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
    end

    for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
      req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
    end

    if me.xp >= req_xp[1000] then
      current_level = 1000
    else
        for i = 1,999 do -- getting current player level based on array
            if req_xp[i] <= me.xp
             and req_xp[i + 1] > me.xp
            then
              current_level = i
              break
            end
        end
    end

    -- end of XP-array

    function auxbox_xp()
        if current_level <= 1000 then
          local xptolvl_float = ((me.xp - req_xp[current_level]))/(req_xp[current_level+1]-req_xp[current_level]) -- % needed for next level
          local lvl_float = current_level + me.remort_level * 75 + xptolvl_float -- combines actual lvl with the % needed for next lvl

          -- checks if player leveled or remorted
            if xptolvl_float >= 1 or xptolvl_float < 0 then
              for i = 1,999 do
                if req_xp[i] <= me.xp
                 and req_xp[i + 1] > me.xp
                then
                  current_level = i
                  break
                end
            end
        end
          
        if os.difftime(os.time(), session_start) > session_time then -- just to reduce the script to every second
          session_time = os.difftime(os.time(), session_start)
          session_d_float = session_time / 60 / 60 / 24
          session_d = math.floor(session_d_float)
          session_h = math.floor((session_d_float - session_d)*24)
          session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
          session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)

          xpgain = me.xp - session_start_xp 
          xps = xpgain/session_time

            if me.age-session_start_age > 0  then
              xpmin = xpgain/(me.age-session_start_age)
            else
              xpmin = 0
            end

          xptolvl = req_xp[current_level + 1] - me.xp
          xpto1k = req_xp[1000] - me.xp

            if xps > 0 then
              timetolvl = xptolvl / xps
              timeto1k = xpto1k / xps
            else
              timetolvl = 0
              timeto1k = 0
            end

          timetolvl_d_float = timetolvl / 60 / 60 / 24
          timetolvl_d = math.floor(timetolvl_d_float)
          timetolvl_h = math.floor((timetolvl_d_float - timetolvl_d)*24)
          timetolvl_m = math.floor(((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60)
          timetolvl_s = math.floor((((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60 - timetolvl_m) * 60)

          timeto1k_d_float = timeto1k / 60 / 60 / 24
          timeto1k_d = math.floor(timeto1k_d_float)
          timeto1k_h = math.floor((timeto1k_d_float - timeto1k_d)*24)
          timeto1k_m = math.floor(((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60)
          timeto1k_s = math.floor((((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60 - timeto1k_m) * 60)
        end
          auxbox_prop_line("XP to Level:", string.format("%d", xptolvl))
          auxbox_prop_line("XP per Minute:" ,string.format("%d", xpmin))
          auxbox_prop_line("Time to Level:" ,string.format("%02.f:%02.f:%02.f:%02.f", timetolvl_d, timetolvl_h, timetolvl_m, timetolvl_s))
    end
end

   
    function auxbox_prop_line(prop_name, prop_val)
      local pvl=0
      if prop_name==nil then prop_name="" end
      if prop_val==nil then prop_val="" end
      local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
      auxbox_next_line = auxbox_next_line + 1
      d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))

        function Items_Left()
           auxbox_blank_line()
		   auxbox_prop_line("Items Left")
		   auxbox_blank_line()
		   auxbox_prop_line("Mega Yellow:", items:get_qty_basecode(363))
		   auxbox_prop_line("Mega Blue:", items:get_qty_basecode(364))
		   auxbox_blank_line()
		   auxbox_prop_line("Omelettes:", items:get_qty_basecode(1380))
		   auxbox_prop_line("Dragon Rations:", items:get_qty_basecode(1399))
		   auxbox_blank_line()
		   auxbox_prop_line("Greater Health:", items:get_qty_basecode(12))
           auxbox_prop_line("Protection:", items:get_qty_basecode(1297))
           auxbox_prop_line("Sanct Lor:", items:get_qty(make_code(286,0,0,18)))
           auxbox_prop_line("Kal Ort Por:", items:get_qty(make_code(286,0,0,13)))
           auxbox_prop_line("Town Portal:", items:get_qty_basecode(293))
		   auxbox_blank_line()
           auxbox_prop_line("Bandages:", items:get_qty_basecode(375))
		   auxbox_prop_line("Arrows:", items:get_qty_basecode(296))
		   auxbox_prop_line("Bullets:", items:get_qty_basecode(1294))
        end
    end
Ive tried a few different things but they all fail. Im beginning to think it might not be possible with the current codes format, ie the way they were initially coded. Does anyone know how to resize the auxbox to take advantage of the extra room above it in the window?
You do not have the required permissions to view the files attached to this post.
Rikimaru

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

User avatar
LordMortiferus
MACRO > me
Posts: 849
Joined: Tue Dec 01, 2009 10:23 pm

Re: Custom Auxbox Creations

Post by LordMortiferus » Wed May 08, 2013 11:52 pm

Nice thread.
Riki, the 5 hit counter was not done by me.
I'll add my ASCII mini maps for the auxbox tomorrow - have to test them with the latest client first.

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

Re: Custom Auxbox Creations

Post by CIAassassin » Wed May 08, 2013 11:59 pm

Oh? That was credited to you in one of the scripts I was sent. Oh well, the owner can step up if they want to.
Rikimaru

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

Chedich
on lolpatrol
Posts: 253
Joined: Wed Jan 14, 2004 12:51 am

Re: Custom Auxbox Creations

Post by Chedich » Thu May 09, 2013 3:46 am

CIAssassin: Mind if I ask how you got your hands on the second script in the first post you made? Seems eerily similar to an early version of my auxbox script.

Since it's already posted I might as well post the latest version that works better.

Code: Select all

filterTextLines=[[Hit the following keys
to filter item types:

w: weapons
W: wearables
p: potions
s: shields
u: usable
j: jewellry
f: food
U: unidentified
h: slot-head
t: slot-torso
l: slot-legs
b: slot-boots
g: slot-gloves
r: slot-rings
n: slot-neck
S: spells & scrolls
G: gems
R: reagants, etc
A: cancel filtering
v: cancel filtering]]

auxbox_next_line = 0
session_time = 0
sessionstart = os.time()

shiftkeys={"Shift","Alt","Ctrl+Shift","Shift+Alt","Ctrl+Alt","Ctrl+Alt+Shift"}
-- Set label as nil to use wl:get_full_name(itemcode, true)
items_pots = 
{
	{["label"]="Greater Yellow Potions", ["itemcode"]=make_code(260,0,15,3)},
	--{["label"]="Mega Yellow Potions", ["itemcode"]=make_code(363,0,0,0)},
	{["label"]="Purple Potions", ["itemcode"]=make_code(360,0,0,0)},
	--{["label"]="Khaki Potions", ["itemcode"]=make_code(380,0,0,0)},
	--{["label"]="White Potions", ["itemcode"]=make_code(354,0,0,0)},
	--{["label"]="Cyan Potions", ["itemcode"]=make_code(356,0,0,0)},
	--{["label"]="Orange Potions", ["itemcode"]=make_code(355,0,0,0)},
	--{["label"]="Brown Potions", ["itemcode"]=make_code(358,0,0,0)},

}

items_scrolls = 
{
	{["label"]="Scroll - GSoH", ["itemcode"]=make_code(1298,0,15,3)},
	{["label"]="Scroll of Protection", ["itemcode"]=make_code(1297,0,0,0)},
	{["label"]="Scroll of Galvinising", ["itemcode"]=make_code(1484,0,0,0)},
	{["label"]="Scroll - VL", ["itemcode"]=make_code(286,0,0,4)},
	{["label"]="Scroll - SL", ["itemcode"]=make_code(286,0,0,18)},
	--{["label"]="Scroll - KOP", ["itemcode"]=make_code(286,0,0,13)},
	--{["label"]="Scroll of Uncurse", ["itemcode"]=make_code(315,0,0,0)},
	--{["label"]="Town Portal Scroll", ["itemcode"]=make_code(293,0,0,0)},

}

items_other = 
{
	{["label"]="Bandages", ["itemcode"]=make_code(375,0,0,0)},
	{["label"]="Wonderous Fish", ["itemcode"]=make_code(279,7,0,0)},
	--{["label"]="Charred Blue Dragon", ["itemcode"]=make_code(1334,0xd,0x02,0x12)},
	--{["label"]="Superior Lava Fish", ["itemcode"]=make_code(279,4,15,4)},
	--{["label"]="Dragon Rations", ["itemcode"]=make_code(1399,0,0,0)},
}

items_coins = 
{
	{["label"]="Adamantium coins", ["itemcode"]=make_code(0x1000044f,0x0,0x0,0x0)},
	{["label"]="Crystal coins", ["itemcode"]=make_code(0x1000f5ca,0x0,0x0,0x0)},
	--{["label"]="Glass coins", ["itemcode"]=make_code(0x1000d5ca,0x0,0x0,0x0)},
}

items_currency = 
{
	{["label"]="Adamantium coins", ["itemcode"]=make_code(0x1000044f,0x0,0x0,0x0)},
	{["label"]="Crystal coins", ["itemcode"]=make_code(0x1000f5ca,0x0,0x0,0x0)},
	{["label"]="Glass coins", ["itemcode"]=make_code(0x1000d5ca,0x0,0x0,0x0)},
  {["label"]="Gold coins", ["itemcode"]=make_code(0x100,0x0,0x0,0x0)},
}

-- XP by LordMortiferus 2013/01/28, rehashed by Brentoboy
-- snip snip
-- beginning of XP-array
req_xp = {}
req_xp[1] = 0 -- fixed XP value
req_xp[2] = 200 -- fixed XP value
req_xp[26] = 93000 -- fixed XP value

for i=3,25 do -- adds XP for lvl 3 to 25 to array
  req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
end

for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
  req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
end

-- snip snip
-- end of XP-array

ched_init=true
ched_xp_arr={}

function ched_xp_init()
	if ched_init then
		ched_xp=me.xp
		ched_currentlvl=me.lvl-(me.remort_level*75)
		ched_lastxp=0
		ched_xp_next_level = 0
		ched_xp_p_fmin = 0
		ched_xp_p_tmin = 0
		ched_xp_lasttickxp = me.xp
		ched_lasttick = 0
		ched_lastname=me.name
		ched_init=false

		for i=1,600 do
			ched_xp_arr[i]=0
		end
	end
end

function ched_strdex_ratio()
  local str = string.format("%.1f", (me:get_str()/(me:get_str()+me:get_dex()))*100)
  local dex = 100-str
  auxbox_prop_line("STR/DEX:", str.."%/"..dex.."%")
end

function auxbox()
   
  local w=d:auxbox_get_width()
  local h=d:auxbox_get_height()
 
  d:auxbox_clear()
  auxbox_next_line = 0 
  if not d:ok_to_draw_play_window() then return; end

	ched_xp_init()
      
  local cd=d:get_curr_display()
  local mode=d:get_statbox_mode()
  local lineNr=0
  local txta=explode("\n", filterTextLines)
  if cd==1 then
  
    if mode==SELECT_ABILITY then
    	auxbox_prop_line("Hit F-key to bind currently")
    	auxbox_prop_line("selected spell")
    	auxbox_blank_line()
    	auxbox_ability_binds()
    elseif mode==SELECT_BUY then
      auxbox_ched_itemsleft("Currency",items_currency)
    else
  
	  	for i=1,#txta do
	  	 auxbox_prop_line(txta[i])
	  	end
	  	auxbox_blank_line()
	  	auxbox_prop_line("Search with /")
	  	if mode==SELECT_READY then
	  		auxbox_prop_line("Press ENTER to equip")
	    elseif mode==SELECT_BANK then
	    	auxbox_prop_line("Press ENTER to transfer one")
	    	auxbox_prop_line("Press Shift+ENTER for 10")
	    	auxbox_prop_line("Press TAB for whole stack")
	    end
	  end
    
  else
  			
			--auxbox_time()	--Not really interesting
			--auxbox_blank_line()
			--auxbox_damage_per_second()
			--auxbox_blank_line()
		--auxbox_prop_line(string.format("%X",me:get_draw_code()))

			XP_Calc()
			auxbox_blank_line()
			DPS_Calc()
			auxbox_blank_line()
			auxbox_ched_itemsleft("Potions",items_pots)
			auxbox_ched_itemsleft("Scrolls",items_scrolls)
			auxbox_ched_itemsleft("Other",items_other)
			auxbox_ched_itemsleft("Coins",items_coins)
			auxbox_blank_line()
			--auxbox_bound_item_basecodes()
			--testitem(make_code(0x1000044f,0x0,0x0,0))
						

		  
		  if d:numlock() then
		  	auxbox_blank_line()
		  	auxbox_prop_line("Please turn numlock off!")
		  end
		 --auxbox_blank_line()
		  --auxbox_prop_line("F12 for main menu.")
		  --auxbox_blank_line()
			--auxbox_f5_message()
  end
   
      
end

function testitem(code)
	auxbox_prop_line(wl:get_full_name(code))
	auxbox_prop_line(items:get_qty(code))
end

--
--make_code(basecode,material,arg1,arg2)
--arg1: 1-14 affix arg2=quantity
--arg1: 0 magic ench, arg2= spell id
--arg1: 15 prefix, arg2=quality (improved,refined,greater,superior,magic,enchanted,etc.)
--
--
--
--arg2: for meat - 0x1? charred, 0x2?, roasted, 0x?1 item, 0x?2 mob, 0x?3 mob.
--arg2: all 0x100 for soulbound
--if the first bit is 1, it'll be cursed
--continues into arg1 and material. probably makes more sense if you look at the finished item code.
--probably assembles it like thus: 0x2211MMBBB
--
--
--

--
--You use 1 nutrition every 6th second
--

-- Color codes:
-- 16(0x10) - white
-- 17(0x11) - yellow(?) tinted white
-- 18(0x12) - light blue
-- 19(0x13) - red
-- 20(0x14) - light orange
-- 21(0x15) - light green
-- 22(0x16) - light purple/pink
-- 23(0x17) - cyan(?)
-- 24(0x18) - gray(dark, ie. log in/out messages)
-- 25(0x19) - orange
-- 26(0x1A) - living (light) green
-- 27(0x1B) - Yellow
-- 28(0x1C) - Purple
-- 29(0x1D) - green
-- 30(0x1E) - green
-- 31(0x1F) - Runic alphabet
--

-- Bound Item Quantities(modified to show basecodes)  - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
function auxbox_bound_item_basecodes()
	local item
	local name
	for i = 1, 50 do	
		item = me.item_binds[i]
		name = wl:get_full_name(item)
		
		if item 
		and not wl:is_tool(item)
		and name ~= "NOTHING" 
		then	
			auxbox_prop_line(name, get_base_code(item))
		end
	end
end

function XP_Calc()
	if ched_xp<me.xp then
		ched_lastxp=me.xp-ched_xp
		ched_xp=me.xp
	end
	if ched_init then
		return
	end
	if ched_lastxp == me.xp
	or ched_lastname ~= me.name then
		ched_init=true
		ched_xp_init()
	end
		
	if (os.difftime(os.time(), ched_lasttick)>0) then --We need to run this once per second
		ched_xp_next_level = (req_xp[(ched_currentlvl+1)]-me.xp)
		if ched_xp_next_level < 0 then --To account for non-meditated levels
			ched_currentlvl = ched_currentlvl + 1
		end
		
		local xpperminuteftotal = 0
		local xpperminutettotal = 0
		for i=1,300 do --5 to 10 minutes back
			ched_xp_arr[(600-(i-1))]=ched_xp_arr[(600-i)]
			xpperminutettotal=xpperminutettotal+ched_xp_arr[(600-(i-1))]
		end
		for i=1,299 do --0 to 5 minutes back
			ched_xp_arr[(300-(i-1))]=ched_xp_arr[(300-i)]
			xpperminuteftotal=xpperminuteftotal+ched_xp_arr[(300-(i-1))]
		end
		ched_xp_arr[1]=me.xp-ched_xp_lasttickxp
		xpperminuteftotal=xpperminuteftotal+ched_xp_arr[1]
		xpperminutettotal=xpperminutettotal+xpperminuteftotal
		ched_xp_p_fmin = math.floor(xpperminuteftotal/5)
		ched_xp_p_tmin = math.floor(xpperminutettotal/10)
		ched_xp_lasttickxp = me.xp
		ched_lasttick=os.time()
	end
	

	auxbox_prop_line("XP to next level:", ched_xp_next_level)
	auxbox_prop_line("XP/min (10 mins):",string.format("%d(%d)",ched_xp_p_tmin,math.floor(ched_xp_next_level/ched_xp_p_tmin)))
	auxbox_prop_line("XP/min (5 mins):",string.format("%d(%d)",ched_xp_p_fmin,math.floor(ched_xp_next_level/ched_xp_p_fmin)))
	auxbox_prop_line("Last XP gain:", ched_lastxp)

end

function DPS_Calc()
	local dwmindmg, dwmaxdmg, dwavgdmg
	dwavgdmg = 0
	local weapons = 1

	auxbox_prop_line("Weapon Delay:", me:get_weapon_delay())
  ched_strdex_ratio()
	auxbox_prop_line("Stat DMG Multiplier:", me:stat_damage_multiplier())

	local offhand = wl:get_type(me.shield)

	if offhand == 87
	then
		dwmindmg = math.floor((wl:get_no_dice(me.shield)+get_modifier(me.shield))*wl:get_material_dmg_mult(me.shield,false))
		dwmaxdmg = math.floor(((wl:get_no_sides(me.shield)*wl:get_no_dice(me.shield))+get_modifier(me.shield))*wl:get_material_dmg_mult(me.shield,false))
		dwavgdmg = (dwmindmg+dwmaxdmg)/2
		weapons=2
	end

	local mindmg = math.floor((me:get_dmg_dice()+get_modifier(me.weapon))*wl:get_material_dmg_mult(me.weapon,false))
	local maxdmg = math.floor(((me:get_dmg_sides()*me:get_dmg_dice())+get_modifier(me.weapon))*wl:get_material_dmg_mult(me.weapon,false))
	local avgdmg = (mindmg+maxdmg)/2
	local wrating = 0
	auxbox_prop_line("Mainhand AVG DMG:", avgdmg)
	auxbox_prop_line("Offhand AVG DMG:", dwavgdmg)
  
	if weapons == 1 then
		wrating = (((avgdmg+dwavgdmg)*me:stat_damage_multiplier())+((me:get_thaco()-get_modifier(me.weapon))*weapons))*(1000/me:get_weapon_delay())
	else
		wrating = (((avgdmg+dwavgdmg)*me:stat_damage_multiplier())+((me:get_thaco()-get_modifier(me.weapon)-get_modifier(me.shield))*weapons))*(1000/me:get_weapon_delay())
	end

	auxbox_prop_line("Weapon rating:", string.format("%0.f",wrating))
end


function auxbox_ched_itemsleft(category,itemarray)
	local lowquantity=5
	local itemlabel=nil
	local quantity=nil

	auxbox_prop_line(" \25"..category..":")

	for i=1,#itemarray do
		itemlabel=itemarray[i].label
		quantity=items:get_qty(itemarray[i].itemcode)

		if not itemlabel then
			itemlabel=wl:get_full_name(itemarray[i].itemcode, true)
		end

	-- adds a space to the end(?)
	--	if quantity <=lowquantity then
	--		quantity="\19"..quantity
	--	end

		auxbox_prop_line(itemlabel..":", quantity)
	end
end

-- explode(seperator, string)
-- from http://lua-users.org/wiki/SplitJoin
function explode(d,p)
  local t, ll
  t={}
  ll=0
  if(#p == 1) then return p end
    while true do
      l=string.find(p,d,ll+1,true) -- find the next d in the string
      if l~=nil then -- if "not not" found then..
        table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
        ll=l+1 -- save just after where we found it for searching next time.
      else
        table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
        break -- Break at end, as it should be, according to the lua manual.
      end
    end
  return t
end

-- Real World Time - Duncan (PD) / Zen (Reg) / Brentoboy (forums)
function auxbox_time()

	auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
	
 
  
   if os.difftime(os.time(), sessionstart) > session_time then -- just to reduce the script to every second
  
    session_time = os.difftime(os.time(), sessionstart)
    session_d_float = session_time / 60 / 60 / 24
    session_d = math.floor(session_d_float)
    session_h = math.floor((session_d_float - session_d)*24)
    session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
    session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)
  end    
  
   if session_d~=nil then
     auxbox_prop_line("Session time:", string.format("%02.f:%02.f:%02.f:%02.f", session_d, session_h, session_m, session_s))	
   end 
end


function auxbox_f5_message()
	auxbox_prop_line("Press Alt-F5 to Reset", "")
end

function auxbox_prop_line(prop_name, prop_val)
  
  local pvl=0
  if prop_name==nil then prop_name="" end
  if prop_val==nil then prop_val="" end
  local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
	auxbox_next_line = auxbox_next_line + 1
	d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
end

function auxbox_blank_line()
	auxbox_next_line = auxbox_next_line + 1
end

function auxbox_ability_binds() 
	local cnt=0			
	for i=10,15 do
		if me.spell_binds[i]~=-1 then
	   auxbox_prop_line(shiftkeys[i-9],spells:get_full_spell_name(me.spell_binds[i]))
	   cnt=cnt+1
	  end
  end
  return cnt
end

--- Damage Per Second -- original script proveded by LordMortiferus
last_session_seconds = 0
last_4_dpst = { g_dpst, g_dpst, g_dpst, g_dpst }
last_4_dtpst = { g_dtpst, g_dtpst, g_dtpst, g_dtpst }
last_dpst = g_dpst
recent_dmg = { 0, 0, 0, 0 }

function auxbox_damage_per_second() 
	local session_seconds = os.time() - sessionstart
	
	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] = 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] = g_dtpst	
	end
	
	if last_dpst ~= g_dpst then
		recent_dmg[4] = recent_dmg[3]
		recent_dmg[3] = recent_dmg[2]
		recent_dmg[2] = recent_dmg[1]
		recent_dmg[1] = g_dpst - last_dpst
		last_dpst = g_dpst
	end
	
	auxbox_prop_line("Dmg Dealt / Sec", string.format("%d", (last_4_dpst[1] - last_4_dpst[4])  / 4))
	auxbox_prop_line("Dmg Taken / Sec", string.format("%d", (last_4_dtpst[1] - last_4_dtpst[4])  / 4))
	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

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

Re: Custom Auxbox Creations

Post by Keighn » Thu May 09, 2013 4:07 am

I modified CIAs a little and was surprised it worked:
current aux.png
I'd like to be able to have various text colored like potions. I saw a color code somewhere but I failed to apply it and it destroyed the box.
I think I want to get rid of the xp per minute and time to level.
I'd rather have current xp points.
I also would like more than the last 4 hits I did and up it to say 6. I'd like this colored Light green
Further options would be the last 6 hits on me colored in bright red.

Can anyone help?

Code: Select all

    auxbox_next_line = 0
    session_time = 0
    sessionstart = os.time()
	function auxbox()
      d:auxbox_clear();
	  auxbox_next_line = 0
      auxbox_real_world_time()
	  auxbox_blank_line()
      auxbox_xp()
	  auxbox_last_few()
	  auxbox_blank_line()
	  Items_Left()
    end

    function auxbox_prop_line(prop_name, prop_val)
      local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
      auxbox_next_line = auxbox_next_line + 1
      d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
    end

    function auxbox_blank_line()
      auxbox_next_line = auxbox_next_line + 1
    end

    function auxbox_real_world_time()
      auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
    end

    session_start_xp = me.xp -- var to calculate xp gain per session
    session_start_age = me.age -- var to calculate time played per session
    session_time = 0
    current_level = 0

    -- beginning of XP-array
    req_xp = {}
    req_xp[1] = 0 -- fixed XP value
    req_xp[2] = 200 -- fixed XP value
    req_xp[26] = 93000 -- fixed XP value

    for i=3,25 do -- adds XP for lvl 3 to 25 to array
      req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
    end

    for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
      req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
    end

    if me.xp >= req_xp[1000] then
      current_level = 1000
    else
        for i = 1,999 do -- getting current player level based on array
            if req_xp[i] <= me.xp
             and req_xp[i + 1] > me.xp
            then
              current_level = i
              break
            end
        end
    end

    -- end of XP-array

    function auxbox_xp()
        if current_level <= 1000 then
          local xptolvl_float = ((me.xp - req_xp[current_level]))/(req_xp[current_level+1]-req_xp[current_level]) -- % needed for next level
          local lvl_float = current_level + me.remort_level * 75 + xptolvl_float -- combines actual lvl with the % needed for next lvl

          -- checks if player leveled or remorted
            if xptolvl_float >= 1 or xptolvl_float < 0 then
              for i = 1,999 do
                if req_xp[i] <= me.xp
                 and req_xp[i + 1] > me.xp
                then
                  current_level = i
                  break
                end
            end
        end
          
        if os.difftime(os.time(), session_start) > session_time then -- just to reduce the script to every second
          session_time = os.difftime(os.time(), session_start)
          session_d_float = session_time / 60 / 60 / 24
          session_d = math.floor(session_d_float)
          session_h = math.floor((session_d_float - session_d)*24)
          session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
          session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)

          xpgain = me.xp - session_start_xp 
          xps = xpgain/session_time

            if me.age-session_start_age > 0  then
              xpmin = xpgain/(me.age-session_start_age)
            else
              xpmin = 0
            end

          xptolvl = req_xp[current_level + 1] - me.xp
          xpto1k = req_xp[1000] - me.xp

            if xps > 0 then
              timetolvl = xptolvl / xps
              timeto1k = xpto1k / xps
            else
              timetolvl = 0
              timeto1k = 0
            end

          timetolvl_d_float = timetolvl / 60 / 60 / 24
          timetolvl_d = math.floor(timetolvl_d_float)
          timetolvl_h = math.floor((timetolvl_d_float - timetolvl_d)*24)
          timetolvl_m = math.floor(((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60)
          timetolvl_s = math.floor((((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60 - timetolvl_m) * 60)

          timeto1k_d_float = timeto1k / 60 / 60 / 24
          timeto1k_d = math.floor(timeto1k_d_float)
          timeto1k_h = math.floor((timeto1k_d_float - timeto1k_d)*24)
          timeto1k_m = math.floor(((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60)
          timeto1k_s = math.floor((((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60 - timeto1k_m) * 60)
        end
          auxbox_prop_line("XP to Level:", string.format("%d", xptolvl))
          auxbox_prop_line("XP per Minute:" ,string.format("%d", xpmin))
          auxbox_prop_line("Time to Level:" ,string.format("%02.f:%02.f:%02.f:%02.f", timetolvl_d, timetolvl_h, timetolvl_m, timetolvl_s))
    end
end


	last_session_seconds = 0
	last_5_dpst = { g_dpst, g_dpst, g_dpst, g_dpst }  
	last_5_dtpst = { g_dtpst, g_dtpst, g_dtpst, g_dtpst }
	last_dpst = g_dpst
	recent_dmg = { 0, 0, 0, 0, }
	function auxbox_last_few()
      local session_seconds = os.time() - sessionstart
   
		if session_seconds > last_session_seconds then
		  last_session_seconds = session_seconds
		  last_5_dpst[4] = last_5_dpst[3]
		  last_5_dpst[3] = last_5_dpst[2]
		  last_5_dpst[2] = last_5_dpst[1]  
		  last_5_dpst[1] = g_dpst

		  last_5_dpst[4] = last_5_dpst[3]
		  last_5_dpst[3] = last_5_dpst[2]
		  last_5_dpst[2] = last_5_dpst[1]  
		  last_5_dpst[1] = g_dtpst   
		end
   
		if last_dpst ~= g_dpst then
		  recent_dmg[4] = recent_dmg[3]
		  recent_dmg[3] = recent_dmg[2]
		  recent_dmg[2] = recent_dmg[1]
		  recent_dmg[1] = g_dpst - last_dpst
		  last_dpst = g_dpst
		end
	   auxbox_prop_line("Last Few Hits:", "")
	   auxbox_prop_line(string.format("%d  %d  %d  %d",recent_dmg[4], recent_dmg[3], recent_dmg[2], recent_dmg[1]))
    end
   
    function auxbox_prop_line(prop_name, prop_val)
      local pvl=0
      if prop_name==nil then prop_name="" end
      if prop_val==nil then prop_val="" end
      local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
      auxbox_next_line = auxbox_next_line + 1
      d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))

function Items_Left()
		   auxbox_prop_line("Items Left")
		   auxbox_prop_line("Mega Yellow:", items:get_qty_basecode(363))
		   auxbox_prop_line("Other Yellow Potions:", items:get_qty_basecode(260))
		   auxbox_prop_line("Mega Blue Potions:", items:get_qty_basecode(364))
		   auxbox_prop_line("Blue Potions:", items:get_qty_basecode(261))
		   auxbox_prop_line("Purple Potions:", items:get_qty_basecode(360))
		   auxbox_prop_line("Brown Potions:", items:get_qty_basecode(358))
		   --auxbox_prop_line("Khaki Potions:", items:get_qty_basecode(380))
		   auxbox_prop_line("White Potions:", items:get_qty_basecode(354))
		   --auxbox_prop_line("Cyan Potions:", items:get_qty_basecode(356))
		   auxbox_prop_line("Orange Potions:", items:get_qty_basecode(355))
		   auxbox_prop_line("Omelettes:", items:get_qty_basecode(1380))
		   auxbox_prop_line("Dragon Rations:", items:get_qty_basecode(1399))
		   --auxbox_prop_line("Greater Health:", items:get_qty_basecode(12))
		   auxbox_prop_line("Scroll of Health:", items:get_qty_basecode(1298)) --should use make_code(1298,0,15,3)
		   auxbox_prop_line("Scroll of Protection:", items:get_qty_basecode(1297))
		   auxbox_prop_line("Sanct Lor:", items:get_qty(make_code(286,0,0,18)))
		   auxbox_prop_line("Black Potions:", items:get_qty_basecode(352))
		   auxbox_prop_line("Kal Ort Por:", items:get_qty(make_code(286,0,0,13)))
		   auxbox_prop_line("Town Portal:", items:get_qty_basecode(293))
		   auxbox_prop_line("Bandages:", items:get_qty_basecode(375))
		   auxbox_prop_line("Arrows:", items:get_qty_basecode(296))
		   auxbox_prop_line("Bullets:", items:get_qty_basecode(1294))
		   auxbox_prop_line("Soul Shards:", items:get_qty_basecode(1283))
        end
    end
You do not have the required permissions to view the files attached to this post.

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

Re: Custom Auxbox Creations

Post by CIAassassin » Thu May 09, 2013 4:57 am

Chedich wrote:CIAssassin: Mind if I ask how you got your hands on the second script in the first post you made? Seems eerily similar to an early version of my auxbox script.

Since it's already posted I might as well post the latest version that works better.
Keighn gave it to me, who got it from wang. Ive been trying to parse your last hit dmg into Sevs DPS calculator. I take NO claim to any of the codes, only the clean ups (line adjustments and tabbings) and general mucking up of the code base.
Keighn wrote:I modified CIAs a little and was surprised it worked:
current aux.png
I'd like to be able to have various text colored like potions. I saw a color code somewhere but I failed to apply it and it destroyed the box.
I think I want to get rid of the xp per minute and time to level.
I'd rather have current xp points.
I also would like more than the last 4 hits I did and up it to say 6. I'd like this colored Light green
Further options would be the last 6 hits on me colored in bright red.

Can anyone help?
I can take a look and delete out the xp timer (which looks broken anyway) and add in a few more dmg counters, I pulled it down to four as it only showed 4 with the old format. I can't do squat about colors.
Rikimaru

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

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

Re: Custom Auxbox Creations

Post by Keighn » Thu May 09, 2013 5:16 am

Ok. 4 is fine anyways. Chuck those xp timers as I mentioned and put in damage to me counter. Maybe someone else will let us know how to do colors and show an example.

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

Re: Custom Auxbox Creations

Post by Keighn » Thu May 09, 2013 5:56 am

Here's the examples in an aux I found for colors. I don't know how to make them work yet though and fail miserably at aux:

Code: Select all

-- Color codes:
-- 16(0x10) - white
-- 17(0x11) - yellow(?) tinted white
-- 18(0x12) - light blue
-- 19(0x13) - red
-- 20(0x14) - light orange
-- 21(0x15) - light green
-- 22(0x16) - light purple/pink
-- 23(0x17) - cyan(?)
-- 24(0x18) - gray(dark, ie. log in/out messages)
-- 25(0x19) - orange
-- 26(0x1A) - living (light) green
-- 27(0x1B) - Yellow
-- 28(0x1C) - Purple
-- 29(0x1D) - green
-- 30(0x1E) - green
-- 31(0x1F) - Runic alphabet
--

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

Re: Custom Auxbox Creations

Post by CIAassassin » Thu May 09, 2013 6:39 am

I give up on trying to color the auxbox lines. I don't know lua, and that's just a bit out of my desire to read.
Rikimaru

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

Chedich
on lolpatrol
Posts: 253
Joined: Wed Jan 14, 2004 12:51 am

Re: Custom Auxbox Creations

Post by Chedich » Thu May 09, 2013 6:45 am

You can't use colors in the auxbox. However if egg decides to copy/paste the chatbox color functionality into the auxbox you should be able to use "\21" to make the rest of the string light green.

As for the xp stuff I would suggest using my functions for that. As it would give you more accurate numbers (xp/min and minutes until level up).

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

Re: Custom Auxbox Creations

Post by Keighn » Thu May 09, 2013 7:35 am

I have all the xp stuff I need. I want to get rid of two of the lines: xp per minute and Time to level. Those are utterly useless to me.

I would like a damage taken line similar to the last 4 hits inflicted.

Again, I'm in the same boat as cia... can't do crap with lua and I try to mess with it and the entire thing goes blank. FUCK ME!

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

Re: Custom Auxbox Creations

Post by CIAassassin » Thu May 09, 2013 7:57 am

Chedich wrote:You can't use colors in the auxbox. However if egg decides to copy/paste the chatbox color functionality into the auxbox you should be able to use "\21" to make the rest of the string light green.

As for the xp stuff I would suggest using my functions for that. As it would give you more accurate numbers (xp/min and minutes until level up).
yay, Im glad to see the \21 thing. That's what I was using to try and adjust the color but it was failing horribly. Good to see I was on the right track though.
Rikimaru

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

Post Reply