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.