hmm. Still getting the same thing.
hmm. Still getting the same thing.
nope same thing. "attempt to index local 'item_data' (a nil value)" centered on this part
Code:if item_data.category == "Weapon" then return gearswap.res.skills:with('id', item_data.skill).en else return "NOT WEAPON" end
the portion of code running the check that fails is thus:
dunno if that last bit is how i'm going to actually make it do that; the function fails as soon as it gets the nil value from the first part. it continues on for a bit after that. the complete function is here:Code:if state.RangedMode.value == 'Ranged' then if get_weapon_type("range") == "Archery" then set_macro_page(3, 19) elseif get_weapon_type("range") == "Marksmanship" then set_macro_page(4, 19) else send_command('gs c set RangedMode Melee', 'gs c WS_macro_set') end
Code:function job_self_command(cmdParams, eventArgs) if cmdParams[1] == 'default_macro_set' then select_default_macro_book() elseif cmdParams[1] == 'WS_macro_set' then if state.RangedMode.value == 'Ranged' then if get_weapon_type("range") == "Archery" then set_macro_page(3, 19) elseif get_weapon_type("range") == "Marksmanship" then set_macro_page(4, 19) else send_command('gs c set RangedMode Melee', 'gs c WS_macro_set') end elseif get_weapon_type("main") == "Great Katana" then set_macro_page(2, 20) elseif get_weapon_type("main") == "Polearm" then set_macro_page(3, 20) elseif get_weapon_type("main") == "Sword" then set_macro_page(4, 20) elseif get_weapon_type("main") == "Dagger" then set_macro_page(5, 20) elseif get_weapon_type("main") == "Club" then set_macro_page(6, 20) elseif get_weapon_type("main") == "Staff" then set_macro_page(7, 20) elseif get_weapon_type("main") == "Hand-to-Hand" then set_macro_page(8, 20) elseif get_weapon_type("main") == "Great Sword" then set_macro_page(9, 20) elseif get_weapon_type("main") == "Axe" then set_macro_page(0, 20) elseif get_weapon_type("main") == "Great Axe" then set_macro_page(1, 20) elseif get_weapon_type("main") == "Scythe" then set_macro_page(1, 19) elseif get_weapon_type("main") == "Katana" then set_macro_page(2, 19) else select_default_macro_book() end elseif cmdParams[1] == 'subjob_macro_set' then if player.sub_job == 'WAR' then set_macro_page(2, 18) elseif player.sub_job == 'DNC' then set_macro_page(5, 18) elseif player.sub_job == 'THF' then set_macro_page(7, 18) elseif player.sub_job == 'NIN' then set_macro_page(4, 18) elseif player.sub_job == 'RNG' then set_macro_page(6, 18) elseif player.sub_job == 'MNK' then set_macro_page(8, 18) else select_default_macro_book() end elseif cmdParams[1] == 'spell_macro_set' then if player.main_job == 'PLD' or player.main_job == 'RDM' or player.main_job == 'BLM' or player.main_job == 'DRK' or player.main_job == 'RUN' or player.sub_job == 'PLD' or player.sub_job == 'RDM' or player.sub_job == 'WHM' or player.sub_job == 'BLM' or player.sub_job == 'DRK' or player.sub_job == 'SCH' or player.sub_job == 'RUN' then set_macro_page(1, 16) else select_default_macro_book() end end end
i think you range gear is not in dats but here is a way to fix it
Code:function get_weapon_type(slot) local item_data = gearswap.res.items:with('name', player.equipment[slot]) if item_data and item_data.category == "Weapon" then return gearswap.res.skills:with('id', item_data.skill).en else return "NOT WEAPON OR NOT IN DATS" end end
Excellent, thank you! Now I just need to figure out how to get windower to recognize f13-24, and how to have a function start itself over
okay, another day another question. I'm trying to get it so that if I have a bow equipped, none of my gearsets will change anything about my ranged/ammo slot. I thought this might be straightforward, but since it doesnt seem to want to work, maybe it's not.
I've placed this in both my global user_setup function and in my job-specific user_setup function but neither worked. so either i goofed, or i'm putting it in the wrong function.Code:if get_weapon_type("range") == "Marksmanship" then disable('range') disable('ammo') elseif get_weapon_type("range") == "Archery" then disable('range') disable('ammo') else enable('range') enable('ammo') end
edit: oh i think i just realized the problem. user_setup is only called on load, so its disabling/enabling based on what i have equipped at that time.. hmm.... got an idea, will report back
in all gearswap files the get_sets function is only parsed at load
in motes include the job-specific user_setup function is only parsed at load or you change sub jobs
yeah, i realized that shortly after posting. well i know that snippet works because when i stick it in my global with no function it disables the range/ammo slots. so i just need to figure out which function to use that would get called any time my gear is being touched. i thought that would be get_gearsets but that didnt work
aight soCode:function update_combat_form() if get_weapon_type("range") == "Marksmanship" then disable('range') disable('ammo') elseif get_weapon_type("range") == "Archery" then disable('range') disable('ammo') else enable('range') enable('ammo') end end
seems to have fixed that.
okay so coming back to the WS snippet; it's mostly working now, but it doesn't identify non-weapon in the main slot as being hand-to-hand. so i tried
which i was sure would work, but it doesn't. just fails to change macro sets without a weapon equipped.Code:if state.RangedMode.value == 'Ranged' then if get_weapon_type("range") == "Archery" then set_macro_page(3, 19) elseif get_weapon_type("range") == "Marksmanship" then set_macro_page(4, 19) else send_command('gs c set RangedMode Melee') end elseif get_weapon_type("main") == "Great Katana" then set_macro_page(2, 20) elseif get_weapon_type("main") == "Polearm" then set_macro_page(3, 20) elseif get_weapon_type("main") == "Sword" then set_macro_page(4, 20) elseif get_weapon_type("main") == "Dagger" then set_macro_page(5, 20) elseif get_weapon_type("main") == "Club" then set_macro_page(6, 20) elseif get_weapon_type("main") == "Staff" then set_macro_page(7, 20) elseif get_weapon_type("main") == "Hand-to-Hand" then set_macro_page(8, 20) elseif get_weapon_type("main") == "Great Sword" then set_macro_page(9, 20) elseif get_weapon_type("main") == "Axe" then set_macro_page(0, 20) elseif get_weapon_type("main") == "Great Axe" then set_macro_page(1, 20) elseif get_weapon_type("main") == "Scythe" then set_macro_page(1, 19) elseif get_weapon_type("main") == "Katana" then set_macro_page(2, 19) else set_macro_page(8, 20) -- h2h end
ahem, well, i was doing some coding that had rather more testable effects today and figured out why....
i'd been editing my backups, not the actual script files. whoops. so it does totally work, exactly as expected. once i... yknow... actually load it in. derp.
However, I do have another question! I'm trying to intercept whenever I cast "Protect" and replace that with the highest tier Protect spell currently available to me, targeting the same person. I thought maybe I could adapt the polearm WS insert function from the samurai file, but my ham-fisted attempt seems to have failed.
Am I even in the ballpark on this one? How do I do that? Also, what argument could I make instead of "startswith"? that would trigger on protectra, as well, which i'd like to avoid.Code:function job_pretarget(spell, action, spellMap, eventArgs) if spell.type == 'WhiteMagic' then if spell.english:startswith("Protect") then send_command('input /ma "Protect V"'..spell.target.raw) send_command('input /ma "Protect IV"'..spell.target.raw) send_command('input /ma "Protect III"'..spell.target.raw) send_command('input /ma "Protect II"'..spell.target.raw) send_command('input /ma "Protect"'..spell.target.raw) eventArgs.cancel = true end end end
oh ok
this is all i can think of
only cast Protect or Protectra and it should auto adjust to the highest you can cast on your main/sub job based on you current lvl, recast timer, and mpCode:function job_pretarget(spell, action, spellMap, eventArgs) if spell.type == 'WhiteMagic' then if spell.english:startswith("Protect") then for _,lvl in ipairs({" V"," IV"," III"," II",""}) do local spellR = gearswap.res.spellRs:with('name', spell.english..""..lvl) if spellR and spell.english != spellR.en and (spellR.levels[player.main_job_id] or spellR.levels[player.sub_job_id]) and (spellR.levels[player.main_job_id] <= player.main_job_level or spellR.levels[player.sub_job_id] <= player.sub_job_level) and windower.ffxi.get_spellR_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then send_command('input /ma "'..spellR.english..''..lvl..'"'..spellR.target.raw) eventArgs.cancel = true break end end end end end
here is some lua help for you:https://www.lua.org/pil/contents.html#P1
Is there a way to make a send_command('bind') keyboard depending on which weapon you have equiped?
sure. you just use the script dlsmd helped me with a few posts ago, replace all my macro switching with your send_commands, then stick the whole shebang in whatever function you want to trigger it.
i goofed up here is the fix (i used ipairs not pairs)
Code:function job_pretarget(spell, action, spellMap, eventArgs) if spell.type == 'WhiteMagic' then if spell.english:startswith("Protect") then for _,lvl in pairs({" V"," IV"," III"," II",""}) do local spellR = gearswap.res.spellRs:with('name', spell.english..""..lvl) if spellR and spell.english ~= spellR.en and (spellR.levels[player.main_job_id] or spellR.levels[player.sub_job_id]) and (spellR.levels[player.main_job_id] <= player.main_job_level or spellR.levels[player.sub_job_id] <= player.sub_job_level) and windower.ffxi.get_spellR_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then send_command('input /ma "'..spellR.english..''..lvl..'"'..spellR.target.raw) eventArgs.cancel = true break end end end end end