Jump to content


Photo

Lua code for the 'commitment' buff & ring usage


    3 replies to this topic

    #1 Gukai

    Gukai

      Advanced Member

    • Members
    • PipPipPip
    • 95 posts

      Posted 27 October 2015 - 08:43 AM

      Hi

      I tried but was unsuccessful in trying to find some lua coding that looks to see if the commitment buff was active, and then looks at 2 equipped rings (Trizek & Capacity) to see if they are ready for usage, and activates the ring.  I want it to check Trizek first and if its not ready to then use the capacity ring... or use the Trizek ring is ready.  

       

      Essentially this is all the lua is going to do.  No gear swapping, no nothing... just purely there for ring review and usage.  Anyone have a way to help?  I really suck when it comes to buffs and luas.

       

      Thanks,

      Juan



      #2 sdahlka

      sdahlka

        Advanced Member

      • Members
      • PipPipPip
      • 324 posts

        Posted 27 October 2015 - 09:49 AM

        extdata = require("extdata")
        res = require 'resources'
        rings = L{"Vocation Ring","Trizek Ring","Capacity Ring","Undecennial Ring","Decennial Ring","Allied Ring","Novennial Ring","Kupofried's Ring","Anniversary Ring",
            "Emperor Band","Empress Band","Chariot Band","Duodec. Ring","Expertise Ring"}
        rings_count = 1
        function get_item_next_use(name)--returns time that you can use the item again
            for _,n in pairs({"inventory","wardrobe"}) do
                for _,v in pairs(gearswap.items[n]) do
                    if type(v) == "table" and v.id ~= 0 and res.items[v.id].en == name then
                        return extdata.decode(v)
                    end
                end
            end
        end
        function xp_cp_ring_equip(ring)--equips given ring
             if auto_ring then
                 enable("left_ring")
                 gearswap.equip_sets('equip_command',nil,{left_ring=ring})
                 disable("left_ring")
             end
        end
        function schedule_xpcp_ring()--schedules equip of selected ring
            local ring_time = os.time(os.date("!*t", get_item_next_use(rings[rings_count]).next_use_time))-os.time()
            if type(xpcpcoring) == "thread" then
                coroutine.close(xpcpcoring)
            end
            xpcpcoring = coroutine.schedule(xp_cp_ring_equip:prepare(rings[rings_count]),(ring_time > 0 and ring_time or 1))
        end
        function check_in_party(name)--returs true if given name is in alliance
             for pt_num,pt in ipairs(alliance) do
                 for pos,party_position in ipairs(pt) do
                     if party_position.name == name then
                        return true
                     end
                 end
             end
        end
        function check_ring_buff()-- returs true if you do not have the buff from xp cp ring
            local xpcprings = {cp=S{"Vocation Ring","Trizek Ring","Capacity Ring"},
                               xp=S{"Undecennial Ring","Decennial Ring","Allied Ring","Novennial Ring","Kupofried's Ring","Anniversary Ring","Emperor Band",
                                    "Empress Band","Chariot Band","Duodec. Ring","Expertise Ring"}}
            if xpcprings.xp:contains(rings[rings_count]) and buffactive['Dedication'] == (check_in_party("Kupofried") and 1 or nil) then
                return true
            elseif xpcprings.cp:contains(rings[rings_count]) and not buffactive['Commitment'] then
                return true
            end
            return false
        end
        function aftercast(spell)
            if rings:contains(player.equipment.left_ring) then
                send_command('wait 3.0;input /item "'..player.equipment.left_ring..'" <me>')
            end
        end
        
        function buff_change(status,event,name,gain,buff_table)
            if S{'Commitment','Dedication'}:contains(name) then
                if gain then
                    enable("left_ring") equip(gear_equip(name,'buff_change'))
                else
                    schedule_xpcp_ring()
                end
            end
        end
        

        set rings_count to the ring you want then (in any function you chose) after you do it once its automatic

        if check_ring_buff() then
            schedule_xpcp_ring()
        end
        

        it will then auto schedule and equip/use the selected ring this is the code i use in my include

         

        for got the buff change rule for unlocking the ring slot


        Edited by sdahlka, 28 October 2015 - 09:51 AM.


        #3 zaxtiss

        zaxtiss

          Advanced Member

        • Members
        • PipPipPip
        • 49 posts

          Posted 29 October 2015 - 10:23 AM

          hmmm your include sounds like something is be interested in possible to have a link?



          #4 sdahlka

          sdahlka

            Advanced Member

          • Members
          • PipPipPip
          • 324 posts

            Posted 29 October 2015 - 11:23 AM

            i cant post it here because it violates the rules set by windower but you can find the link on the BGforum's gearswap shop thread






            1 user(s) are reading this topic

            0 members, 1 guests, 0 anonymous users