Because I suck at this gearswap shit. Anyways, carry on.
I'm trying to add some Acc gear functions to a new gearswap. (I want 4 options instead of the 2 I've been using)
Here is the error message:
Gearswap: Loaded your Sirtaint_BLU.lua file!
Gearswap: Lua runtime error: gearswap/flow.lua:346:
Gearswap has detected an error in the user function get_set:
...86)windower4/addons/gearswap/data/Sirtaint_BLU.lua:34: attempt to call global 'update_combat_form' (a nil value)
Here is my lua.
Spoiler: show
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job. Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------
-- Initialization function for this job file.
function get_sets()
mote_include_version = 2
-- Load and initialize the include file.
include('Mote-Include.lua')
end
-- Setup vars that are user-independent. state.Buff vars initialized here will automatically be tracked.
function job_setup()
state.Buff.Hasso = buffactive.Hasso or false
state.Buff.Seigan = buffactive.Seigan or false
state.Buff.Sekkanoki = buffactive.Sekkanoki or false
state.Buff.Sengikori = buffactive.Sengikori or false
state.Buff['Meikyo Shisui'] = buffactive['Meikyo Shisui'] or false
end
-------------------------------------------------------------------------------------------------------------------
-- User setup functions for this job. Recommend that these be overridden in a sidecar file.
-------------------------------------------------------------------------------------------------------------------
-- Setup vars that are user-dependent.
function user_setup()
state.OffenseModeptions('Normal', 'LowAcc', 'MidAcc', 'MaxAcc')
state.HybridModeptions('Normal', 'LightPDT', 'FullPDT')
state.WeaponskillModeptions('Normal', 'LowAcc', 'MaxAcc')
state.PhysicalDefenseModeptions('PDT', 'Reraise')
update_combat_form()
-- Additional local binds
send_command('bind ^` input /ja "Hasso" <me>')
send_command('bind !` input /ja "Seigan" <me>')
select_default_macro_book()
end
-- Called when this job file is unloaded (eg: job change)
function user_unload()
send_command('unbind ^`')
send_command('unbind !-')
end
-- Define sets and vars used by this job file.
function init_gear_sets()
--------------------------------------
-- Start defining the sets
--------------------------------------
-- Precast Sets
-- Precast sets to enhance JAs
sets.precast.JA.Meditate = {head="Wakido Kabuto",hands="Sakonji Kote +1",back="Smertrios's Mantle"}
sets.precast.JA['Warding Circle'] = {head="Myochin Kabuto"}
sets.precast.JA['Blade Bash'] = {hands="Sakonji Kote +1"}
sets.precast.JA.Hasso = {hands="Wakido Kote +3"}
-- Waltz set (chr and vit)
sets.precast.Waltz = {ammo="Sonia's Plectrum",
head="Yaoyotl Helm",
body="Otronif Harness +1",hands="Buremte Gloves",ring1="Spiral Ring",
back="Iximulew Cape",waist="Caudata Belt",legs="Karieyh Brayettes +1",feet="Otronif Boots +1"}
-- Don't need any special gear for Healing Waltz.
sets.precast.Waltz['Healing Waltz'] = {}
-- Weaponskill sets
-- Default set for any weaponskill that isn't any more specifically defined
sets.precast.WS = {}
sets.precast.WS.LowAcc = {}
sets.precast.WS.MaxAcc = {}
-- Specific weaponskill sets. Uses the base set if an appropriate WSMod version isn't found.
sets.precast.WS['Savage Blade'] = set_combine(sets.precast.WS, {neck="Fotia Gorget"})
sets.precast.WS['Savage Blade'].LowAcc = set_combine(sets.precast.WS.LowAcc, {neck="Fotia Gorget"})
sets.precast.WS['Savage Blade'].MaxAcc = set_combine(sets.precast.WS.MaxACC, {waist="Fotia Belt"})
-- Midcast Sets
sets.midcast.FastRecast = {
head="Yaoyotl Helm",
body="Otronif Harness +1",hands="Otronif Gloves",
legs="Phorcys Dirs",feet="Otronif Boots +1"}
-- Sets to return to when not performing an action.
-- Resting sets
sets.resting = {neck="Wiglen Gorget",ring1="Sheltered Ring",ring2="Paguroidea Ring"}
-- Idle sets (default idle set not needed since the other three are defined, but leaving for testing purposes)
sets.idle.Town = {
ammo="Staunch Tathlum +1",
head="Twilight Helm",
body="Hiza. Haramaki +1",
hands={ name="Sakonji Kote +1", augments={'Enhances "Blade Bash" effect',}},
legs="Arjuna Breeches",
feet="Danzo Sune-Ate",
neck="Sanctity Necklace",
waist="Flume Belt",
left_ear="Odnowa Earring",
right_ear="Odnowa Earring +1",
left_ring="Sheltered Ring",
right_ring="Paguroidea Ring",
back="Shadow Mantle"}
sets.idle.Field = {
ammo="Staunch Tathlum +1",
head="Twilight Helm",
body="Hiza. Haramaki +1",
hands={ name="Sakonji Kote +1", augments={'Enhances "Blade Bash" effect',}},
legs="Arjuna Breeches",
feet="Danzo Sune-Ate",
neck="Sanctity Necklace",
waist="Flume Belt",
left_ear="Odnowa Earring",
right_ear="Odnowa Earring +1",
left_ring="Sheltered Ring",
right_ring="Paguroidea Ring",
back="Shadow Mantle"}
sets.idle.Weak = {
ammo="Staunch Tathlum +1",
head="Twilight Helm",
body="Twilight Mail",
hands={ name="Sakonji Kote +1", augments={'Enhances "Blade Bash" effect',}},
legs="Arjuna Breeches",
feet="Danzo Sune-Ate",
neck="Sanctity Necklace",
waist="Flume Belt",
left_ear="Odnowa Earring",
right_ear="Odnowa Earring +1",
left_ring="Sheltered Ring",
right_ring="Paguroidea Ring",
back="Shadow Mantle"}
-- Defense sets
sets.defense.PDT = {
ammo="Staunch Tathlum +1",
head="Ken. Jinpachi",
body="Wakido Domaru +3",
hands="Sakonji Kote +1",
legs="Ken. Hakama",
feet="Plumb Boots",
neck="Loricate Torque +1",
waist="Flume Belt +1",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Defending Ring",
right_ring="Dark Ring",
back="Moonbeam Cape",
}
sets.defense.Reraise = {
head="Twilight Helm",neck="Twilight Torque",ear1="Bladeborn Earring",ear2="Steelflash Earring",
body="Twilight Mail",hands="Buremte Gloves",ring1="Defending Ring",ring2="Paguroidea Ring",
back="Shadow Mantle",waist="Flume Belt",legs="Karieyh Brayettes +1",feet="Otronif Boots +1"}
sets.defense.MDT = {ammo="Demonry Stone",
head="Yaoyotl Helm",neck="Twilight Torque",ear1="Bladeborn Earring",ear2="Steelflash Earring",
body="Otronif Harness +1",hands="Otronif Gloves",ring1="Defending Ring",ring2="Shadow Ring",
back="Engulfer Cape",waist="Flume Belt",legs="Karieyh Brayettes +1",feet="Otronif Boots +1"}
sets.Kiting = {feet="Danzo Sune-ate"}
sets.Reraise = {head="Twilight Helm",body="Twilight Mail"}
-- Engaged sets
-- Variations for TP weapon and (optional) offense/defense modes. Code will fall back on previous
-- sets if more refined versions aren't defined.
-- If you create a set with both offense and defense modes, the offense mode should be first.
-- EG: sets.engaged.Dagger.Accuracy.Evasion
-- Normal melee group
-- Delay 450 GK, 25 Save TP => 65 Store TP for a 5-hit (25 Store TP in gear)
sets.engaged = {
ammo="Ginsen",
head="Flam. Zucchetto +2",
body="Kasuga domaru +1",
hands="Wakido kote +3",
legs="Ryuo hakama +1",
feet="Ryuo Sune-Ate +1",
neck="Moonlight nodowa",
waist="Ioskeha Belt",
left_ear="Telos Earring",
right_ear="Dedition Earring",
left_ring="Niqmaddu Ring",
right_ring="Flamma Ring",
back={ name="Smertrios's Mantle", augments={'DEX+20','Accuracy+20 Attack+20','Accuracy+10','"Dbl.Atk."+10',}},
}
sets.engaged.LowAcc = {
ammo="Ginsen",
head="Flam. Zucchetto +2",
body="Kendatsuba samue",
hands="Wakido Kote +3",
legs="Kendatsuba hakama",
feet="Flam. gambieras +2",
neck="Moonlight Nodowa",
waist="Ioskeha Belt",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Niqmaddu Ring",
right_ring="Flamma Ring",
back={ name="Smertrios's Mantle", augments={'DEX+20','Accuracy+20 Attack+20','Accuracy+10','"Dbl.Atk."+10',}},
}
sets.engaged.MidAcc = {
ammo="Ginsen",
head="Flam. Zucchetto +2",
body="Kendatsuba samue",
hands="Wakido Kote +3",
legs="Kendatsuba hakama",
feet="Flam. gambieras +2",
neck="Moonlight Nodowa",
waist="Ioskeha Belt",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Niqmaddu Ring",
right_ring="Flamma Ring",
back={ name="Smertrios's Mantle", augments={'DEX+20','Accuracy+20 Attack+20','Accuracy+10','"Dbl.Atk."+10',}},
}
sets.engaged.MaxAcc = {
ammo="Ginsen",
head="Flam. Zucchetto +2",
body="Kendatsuba samue",
hands="Wakido Kote +3",
legs="Kendatsuba hakama",
feet="Flam. gambieras +2",
neck="Moonlight Nodowa",
waist="Ioskeha Belt",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Niqmaddu Ring",
right_ring="Flamma Ring",
back={ name="Smertrios's Mantle", augments={'DEX+20','Accuracy+20 Attack+20','Accuracy+10','"Dbl.Atk."+10',}},
}
sets.engaged.PDT = {ammo="Staunch Tathlum +1",
head="Ken. Jinpachi",
body="Wakido Domaru +3",
hands="Wakido Kote +3",
legs="Ken. Hakama",
feet="Ryuo Sune-Ate +1",
neck="Loricate Torque +1",
waist="Ioskeha Belt",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Defending Ring",
right_ring={ name="Dark Ring", augments={'Magic dmg. taken -5%','Phys. dmg. taken -5%',}},
back="Moonbeam Cape",
}
sets.engaged.LowAcc.PDT = {ammo="Staunch Tathlum +1",
head="Ken. Jinpachi",
body="Wakido Domaru +3",
hands="Wakido Kote +3",
legs="Ken. Hakama",
feet="Ryuo Sune-Ate +1",
neck="Loricate Torque +1",
waist="Ioskeha Belt",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Defending Ring",
right_ring={ name="Dark Ring", augments={'Magic dmg. taken -5%','Phys. dmg. taken -5%',}},
back="Moonbeam Cape",
}
sets.engaged.MidAcc.PDT = {ammo="Staunch Tathlum +1",
head="Ken. Jinpachi",
body="Wakido Domaru +3",
hands="Wakido Kote +3",
legs="Ken. Hakama",
feet="Ryuo Sune-Ate +1",
neck="Loricate Torque +1",
waist="Ioskeha Belt",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Defending Ring",
right_ring={ name="Dark Ring", augments={'Magic dmg. taken -5%','Phys. dmg. taken -5%',}},
back="Moonbeam Cape",
}
sets.engaged.MaxAcc.PDT = {ammo="Staunch Tathlum +1",
head="Ken. Jinpachi",
body="Wakido Domaru +3",
hands="Wakido Kote +3",
legs="Ken. Hakama",
feet="Ryuo Sune-Ate +1",
neck="Loricate Torque +1",
waist="Ioskeha Belt",
left_ear="Cessance Earring",
right_ear="Telos Earring",
left_ring="Defending Ring",
right_ring={ name="Dark Ring", augments={'Magic dmg. taken -5%','Phys. dmg. taken -5%',}},
back="Moonbeam Cape",
}
sets.engaged.Reraise = {}
sets.engaged.LowAcc.Reraise = {}
sets.engaged.MidAcc.Reraise = {}
sets.engaged.MaxAcc.Reraise = {}
end
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------
-- Set eventArgs.handled to true if we don't want any automatic target handling to be done.
function job_pretarget(spell, action, spellMap, eventArgs)
if spell.type == 'WeaponSkill' then
-- Change any GK weaponskills to polearm weaponskill if we're using a polearm.
if player.equipment.main=='Quint Spear' or player.equipment.main=='Quint Spear' then
if spell.english:startswith("Tachi:") then
send_command('@input /ws "Penta Thrust" '..spell.target.raw)
eventArgs.cancel = true
end
end
end
end
-- Run after the default precast() is done.
-- eventArgs is the same one used in job_precast, in case information needs to be persisted.
function job_post_precast(spell, action, spellMap, eventArgs)
if spell.type:lower() == 'weaponskill' then
if state.Buff.Sekkanoki then
equip(sets.buff.Sekkanoki)
end
if state.Buff.Sengikori then
equip(sets.buff.Sengikori)
end
if state.Buff['Meikyo Shisui'] then
equip(sets.buff['Meikyo Shisui'])
end
end
end
-- Run after the default midcast() is done.
-- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
function job_post_midcast(spell, action, spellMap, eventArgs)
-- Effectively lock these items in place.
if state.HybridMode.value == 'Reraise' or
(state.DefenseMode.value == 'Physical' and state.PhysicalDefenseMode.value == 'Reraise') then
equip(sets.Reraise)
end
end
-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------
-- Called by the 'update' self-command, for common needs.
-- Set eventArgs.handled to true if we don't want automatic equipping of gear.
function job_update(cmdParams, eventArgs)
update_combat_form()
end
-- Set eventArgs.handled to true if we don't want the automatic display to be run.
function display_current_job_state(eventArgs)
end
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
set_macro_page(1, 1)
end
Userfunctions (unedited from motenns)
Spoiler: show
--Copyright (c) 2013~2016, Byrthnoth
--All rights reserved.
--Redistribution and use in source and binary forms, with or without
--modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of <addon name> nor the
-- names of its contributors may be used to endorse or promote products
-- derived from this software without specific prior written permission.
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
--DISCLAIMED. IN NO EVENT SHALL <your name> BE LIABLE FOR ANY
--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- Functions that are directly exposed to users --
function set_language(lang)
if _global.current_event ~= 'get_sets' then
error('\nGearSwap: set_language() is only valid in the get_sets function', 2)
return
end
if lang and type(lang) == 'string' and (lang == 'english' or lang == 'japanese') then
rawset(_G,'language',lang)
refresh_globals()
else
error('\nGearSwap: set_language() was passed an invalid value ('..tostring(lang)..'). (must be a string)', 2)
end
end
function debug_mode(boolean)
if type(boolean) == "boolean" then _settings.debug_mode = boolean
elseif boolean == nil then
_settings.debug_mode = true
else
error('\nGearSwap: show_swaps() was passed an invalid value ('..tostring(boolean)..'). (true/no value/nil=on, false=off)', 2)
end
end
function show_swaps(boolean)
if type(boolean) == "boolean" then _settings.show_swaps = boolean
elseif boolean == nil then
_settings.show_swaps = true
else
error('\nGearSwap: show_swaps() was passed an invalid value ('..tostring(boolean)..'). (true/no value/nil=on, false=off)', 2)
end
end
function cancel_spell(boolean)
if _global.current_event ~= 'precast' and _global.current_event ~= 'pretarget' and _global.current_event ~= 'filtered_action' then
error('\nGearSwap: cancel_spell() is only valid in the precast, pretarget, or filtered_action functions', 2)
return
end
if type(boolean) == "boolean" then _global.cancel_spell = boolean
elseif boolean == nil then
_global.cancel_spell = true
else
error('\nGearSwap: cancel_spell() was passed an invalid value ('..tostring(boolean)..'). (true/no value/nil=Cancel the spell, false=do not cancel the spell)', 2)
end
end
function move_spell_target(position_table)
if _global.current_event ~= 'precast' then
error('\nGearSwap: move_spell_target() is only valid in the precast function', 2)
return
end
if type(position_table) == 'table' and type(position_table.x or position_table.X) == 'number' and
type(position_table.y or position_table.Y) == 'number' and
type(position_table.z or positino_table.Z) == 'number' then
_global.target_arrow.x = position_table.x or position_table.X
_global.target_arrow.y = position_table.y or position_table.Y
_global.target_arrow.z = position_table.z or position_table.Z
print_set(_global.target_arrow)
else
error('\nGearSwap: move_spell_target() was passed an invalid value ('..tostring(position_table)..'). Should be a table with x, y, and z keys (offset from target)', 2)
end
end
function change_target(name)
if _global.current_event ~= 'pretarget' then
error('\nGearSwap: change_target() is only valid in the pretarget function', 2)
return
end
if name and type(name)=='string' then
if valid_target(name) then
_,_global.new_target = valid_target(name)
else
error('\nGearSwap: change_target() was passed an invalid value ('..tostring(name)..'). (must be a valid target)', 2)
end
else
error('\nGearSwap: change_target() was passed an invalid value ('..tostring(name)..'). (must be a string)', 2)
end
end
function cast_delay(delay)
if _global.current_event ~= 'precast' and _global.current_event ~= 'pretarget' then
error('\nGearSwap: cast_delay() is only valid in the precast and pretarget functions', 2)
return
end
if tonumber(delay) then
_global[_global.current_event.."_cast_delay"] = tonumber(delay)
else
error('\nGearSwap: cast_delay() was passed an invalid value ('..tostring(delay)..'). (cast delay must be a number of seconds)', 2)
end
end
-- Combines the provided gear sets into a new set. Returns the result.
function set_combine(...)
return set_merge(false,{}, ...)
end
-- Combines the provided gear sets into the equip_list set.
function equip(...)
set_merge(true,equip_list, ...)
end
function disable(...)
local disable_tab = {...}
if type(disable_tab[1]) == 'table' then
disable_tab = disable_tab[1] -- Compensates for people passing a table instead of a series of strings.
end
for i,v in pairs(disable_tab) do
if slot_map[v] then
rawset(disable_table,slot_map[v],true)
else
error('\nGearSwap: disable error, passed an unrecognized slot name. ('..tostring(v)..')',2)
end
end
end
function enable(...)
local enable_tab = {...}
if type(enable_tab[1]) == 'table' then
enable_tab = enable_tab[1] -- Compensates for people passing a table instead of a series of strings.
end
local sending_table = {}
for i,v in pairs(enable_tab) do
local local_slot = get_default_slot(v)
if local_slot then
disable_table[toslotid(v)] = false
if not_sent_out_equip[local_slot] then
sending_table[local_slot] = not_sent_out_equip[local_slot]
not_sent_out_equip[local_slot] = nil
end
else
error('\nGearSwap: enable error, passed an unrecognized slot name. ('..tostring(v)..')',2)
end
end
return sending_table
end
function user_enable(...)
local sending_table = enable(...)
if table.length(sending_table) > 0 then
equip(sending_table)
end
return sending_table
end
function command_enable(...)
local sending_table = enable(...)
if table.length(sending_table) > 0 then
refresh_globals()
equip_sets('equip_command',nil,sending_table)
end
end
function print_set(set,title)
if not set then
if title then
error('\nGearSwap: print_set error, '..windower.to_shift_jis(tostring(title))..' set is nil.', 2)
else
error('\nGearSwap: print_set error, set is nil.', 2)
end
return
elseif type(set) ~= 'table' then
if title then
error('\nGearSwap: print_set error, '..windower.to_shift_jis(tostring(title))..' set is not a table.', 2)
else
error('\nGearSwap: print_set error, set is not a table.', 2)
end
end
if table.length(set) == 0 then
if title then
msg.add_to_chat(1,'------------------'.. windower.to_shift_jis(tostring(title))..' -- Empty Table -----------------')
else
msg.add_to_chat(1,'-------------------------- Empty Table -------------------------')
end
return
elseif title then
msg.add_to_chat(1,'------------------------- '..windower.to_shift_jis(tostring(title))..' -------------------------')
else
msg.add_to_chat(1,'----------------------------------------------------------------')
end
local function print_element(key,value)
if type(value) == 'table' and value.name then
msg.add_to_chat(8,windower.to_shift_jis(tostring(k ey))..' '..windower.to_shift_jis(tostring(value.name))..' (Adv.)')
else
msg.add_to_chat(8,windower.to_shift_jis(tostring(k ey))..' '..windower.to_shift_jis(tostring(value)))
end
end
local function cmp_key(key,tab)
for k in pairs(tab) do
if k:lower() == key:lower() then
return k
end
end
end
if #set == table.length(set) then -- If it is a list (keyed by continuous whole number starting at 1), then print it out in order
for key,value in ipairs(set) do
print_element(key,value)
end
else -- Otherwise, try to print out the gear in order and then everything else.
for _,key in ipairs({'main','sub','ranged','range','ammo','head ','neck','lear','ear1','learring','left_ear','rear ','ear2','rearring','right_ear','body','hands','lr ing','ring1','left_ring','rring','ring2','right_ri ng','back','waist','legs','feet'}) do
local k = cmp_key(key,set)
if k then
print_element(k,set[k])
end
end
for key,value in pairs(set) do
if not slot_map[key] then
print_element(key,set[key])
end
end
end
msg.add_to_chat(1,'----------------------------------------------------------------')
end
function send_cmd_user(command)
if string.byte(1) ~= 0x40 then
command='@'..command
end
windower.send_command(command)
end
function register_event_user(str,func)
if type(func)~='function' then
error('\nGearSwap: windower.register_event() was passed an invalid value ('..tostring(func)..'). (must be a function)', 2)
elseif type(str) ~= 'string' then
error('\nGearSwap: windower.register_event() was passed an invalid value ('..tostring(str)..'). (must be a string)', 2)
end
local id = windower.register_event(str,user_equip_sets(func))
registered_user_events[id] = true
return id
end
function raw_register_event_user(str,func)
if type(func)~='function' then
error('\nGearSwap: windower.register_event() was passed an invalid value ('..tostring(func)..'). (must be a function)', 2)
elseif type(str) ~= 'string' then
error('\nGearSwap: windower.register_event() was passed an invalid value ('..tostring(str)..'). (must be a string)', 2)
end
local id = windower.register_event(str,setfenv(func,user_env) )
registered_user_events[id] = true
return id
end
function unregister_event_user(id)
if type(id)~='number' then
error('\nGearSwap: windower.unregister_event() was passed an invalid value ('..tostring(id)..'). (must be a number)', 2)
end
windower.unregister_event(id)
registered_user_events[id] = nil
end
function user_equip_sets(func)
return setfenv(function(...)
if not gearswap.gearswap_disabled then
gearswap.refresh_globals(true)
return gearswap.equip_sets(func,nil,...)
end
end,user_env)
end
function user_unhandled_command(func)
if type(func) ~= 'function' then
error('\nGearSwap: unhandled_command was passed an invalid value ('..tostring(func)..'). (must be a function)', 2)
end
unhandled_command_events[#unhandled_command_events+1] = setfenv(func,user_env)
end
function include_user(str, load_include_in_this_table)
if not (type(str) == 'string') then
error('\nGearSwap: include() was passed an invalid value ('..tostring(str)..'). (must be a string)', 2)
end
str = str:lower()
if type(package.loaded[str]) == 'table' then
return package.loaded[str]
elseif T{'pack'}:contains(str) then
return
end
if str:sub(-4)~='.lua' then str = str..'.lua' end
local path, loaded_values = pathsearch({str})
if not path then
error('\nGearSwap: Cannot find the include file ('..tostring(str)..').', 2)
end
local f, err = loadfile(path)
if f and not err then
if load_include_in_this_table and type(load_include_in_this_table) == 'table' then
setmetatable(load_include_in_this_table, {__index=user_env._G})
setfenv(f, load_include_in_this_table)
pcall(f, load_include_in_this_table)
return load_include_in_this_table
else
setfenv(f,user_env)
return f()
end
else
error('\nGearSwap: Error loading file ('..tostring(str)..'): '..err, 2)
end
end
-- Allow the user to set a path subdirectory to check when searching for included files.
-- This path is checked as a subdirectory to each fixed path, before the fixed path itself is checked.
-- Path argument can only be a string; otherwise this is set to nil.
function user_include_path(path)
if type(path) == 'string' then
include_user_path = path
else
include_user_path = nil
end
end
function user_midaction(bool)
if bool == false then
for i,v in pairs(command_registry) do
if v.midaction then
command_registry[i].midaction = false
end
end
end
for i,v in pairs(command_registry) do
if type(v) == 'table' and v.midaction then
return true, v.spell
end
end
return false
end
function user_pet_midaction(bool)
if bool == false then
for i,v in pairs(command_registry) do
if v.pet_midaction then
command_registry.pet_midaction = false
end
end
end
for i,v in pairs(command_registry) do
if v.pet_midaction then
return true, v.spell
end
end
return false
end
function add_to_chat_user(num,str)
local backup_str
if type(num) == 'string' then
-- It was passed a string as the first argument.
str = not tonumber(str) and str or num
num = 8
elseif not num and str and type(str) == 'string' then
-- It only needs the number.
num=8
end
if language == 'japanese' then
msg.add_to_chat(num,windower.to_shift_jis(str))
else
msg.add_to_chat(num,str)
end
end
function user_sleep(delay)
if not delay then
error('\nGearSwap: coroutine.sleep() not passed a delay value', 2)
elseif type(delay) ~= 'number' or delay < 0 then
error('\nGearSwap: coroutine.sleep() was passed an invalid value ('..tostring(delay)..'). (must be a number >= 0)', 2)
else
coroutine.yield('sleep',delay)
end
end
function user_yield()
coroutine.yield('yield')
end
-- Define the user windower functions.
user_windower = {register_event = register_event_user, raw_register_event = raw_register_event_user,
unregister_event = unregister_event_user, send_command = send_cmd_user,add_to_chat=add_to_chat_user}
user_coroutine = coroutine
user_coroutine.sleep = user_sleep
user_coroutine.yield = user_yield
setmetatable(user_windower,{__index=windower})
Maybe I'm going about it wrong? My goal is 4 acc options for gear sets.