Not ingame right now, but I suspect you also need to change "gearswap.res.spellRs" to "gearswap.res.spells". Find and replace gone wild?
Not ingame right now, but I suspect you also need to change "gearswap.res.spellRs" to "gearswap.res.spells". Find and replace gone wild?
i missed that as well
good your learning
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.spells: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
progress. with the replace-gone-wild in mind, ive fixed a few other things so that it's almost working- but it's trying to cast "Protect V V"
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.spells: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_spell_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then send_command('input /ma "'..spellR.english..''..lvl..'"'..spell.target.raw) eventArgs.cancel = true break end end end end end
i said to only cast /ma "Protect" or /ma "Protectra" do not cast any other like Protect/Protectra II/III/IV/V
the code gets the highest you can cast based on job lvl/MP/recast and auto adjusts
i found a minor bug fixed
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.spells:with('name', spell.english..""..lvl) if spellR and spell.english == spellR.en then break elseif 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.en..''..lvl..'"'..spellR.target.raw) eventArgs.cancel = true break end end end end end
yep, only casting the lowest tier. actually noticed the ..lvl..thing on my own, but good to know i'm starting to catch on.
final product, fully functional:
Code:function job_pretarget(spell, action, spellMap, eventArgs) if spell.type == 'WhiteMagic' then if spell.english:startswith("Protect") or spell.english:startswith("Shell") then for _,lvl in pairs({" V"," IV"," III"," II",""}) do local spellR = gearswap.res.spells:with('name', spell.english..""..lvl) if spellR and spell.english == spellR.en then break elseif 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_spell_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then send_command('input /ma "'..spellR.english..'"'..spell.target.raw) eventArgs.cancel = true break end end end end end
i for got to include the most important part in my last post
Code:function job_pretarget(spell, action, spellMap, eventArgs) if spell.type == 'WhiteMagic' then --checks to see if the spell used starts with Protect if spell.english:startswith("Protect") then --processes from highest to lowest level of spell for _,lvl in pairs({" V"," IV"," III"," II",""}) do --grabs spell data from resorces local spellR = gearswap.res.spells:with('name', string.mgsub(spell.en, "%s.+", "")..'"'..lvl) --checks to see if spellR is nil if spellR then --verifies that the player can cast the spell --checks to see if the spellR is the same as currently trying to cast if spell.english == spellR.en and --checks to see if current spell is on recast windower.ffxi.get_spellR_recasts()[spellR.recast_id] == 0 and --checks to see if player has enuf MP to cast spell spellR.mp_cost <= player.mp then --breaks out of the for loop break --checks to see if the spellR is not the same as currently trying to cast elseif spell.english ~= spellR.en and --verifies the current player job setup can cast the spell (spellR.levels[player.main_job_id] or spellR.levels[player.sub_job_id]) and --verifies that current Main or Sub job can cast the spell at it correct level (spellR.levels[player.main_job_id] <= player.main_job_level or spellR.levels[player.sub_job_id] <= player.sub_job_level) and --checks to see if current spell is on recast windower.ffxi.get_spellR_recasts()[spellR.recast_id] == 0 and --checks to see if player has enuf MP to cast spell spellR.mp_cost <= player.mp then --cancels the current spell eventArgs.cancel = true --changes the current spell to the new one send_command('input /ma "'..spellR.en..'"'..spellR.target.raw) --breaks out of the for loop break end end end end end end
sorry my mind works in mysterious ways
that doesn't seem to want to work. Just yields the base spell. I noticed a few places where 'get_spell_recasts' got replaced with get_spellR_recasts, and corrected that, but that still didn't fix it.
with this you will get some things in the console related to what it is doing
i really dont like using ' instead of " for strings because of the strings with ' unless it is absolutely necessaryCode: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 print("current spell checking = "..string.mgsub(spell.english, "%s.+", "")..""..lvl) local spellR = gearswap.res.spells:with('name', string.mgsub(spell.english, "%s.+", "")..""..lvl) if spellR then print("spellR is good") if spell.english == spellR.en and windower.ffxi.get_spell_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then print("spell confirmed as casted spell and is good to cast") print("casted spell = "..spell.english) break elseif 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_spell_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then print("spell confirmed as new spell and is good to cast = "..spellR.en) eventArgs.cancel = true send_command('input /ma "'..spellR.en..'"'..spellR.target.raw) break end end end print("spell test end") end end end
for things like: send_command('input /ma "'..spellR.en..'"'..spellR.target.raw)
okay finally got a chance to test it. fixed it trying to call spellR.target.raw and it works. thanks dude
So I started working on my DRK .lua and I'm having the same problem my COR lua was having on the last page. If I change jobs, I have to restart windower or my F9 toggles don't work. (reloading gearswap doesn't work) Is there a workaround for this, or do I just need to keep restarting? =/
https://pastebin.com/UH9E4xzY - COR
https://pastebin.com/9arx29xY - DRK
There are some bind commands in there, but I don't quite understand them. Q_Q
For comparison's sake, do you have a link to one where the binds work?
Those same ones work when I log in. But if I change jobs at all, they stop working when I change back to them. (There are no other .lua)
I can't see what's doing it, but we can fix this - next time you log in, make sure it's working and first thing do '//listbinds' and look for what f9 is.
Add a line, send_command('bind f9 YOUR_TEXT_HERE') right after get_sets() at the top of each file, where YOUR_TEXT_HERE is whatever the initial bind is - probably something like "gs c C1". This should rebind that key every time you change to that job.
Something in your scripts or macros is doing the bind to begin with, but I don't see it here.
I think something in my GEO lua kills my binds. When I load and bounce between DRK and COR, the keybinds stay the same, but when I swap to GEO it messes them all up and changing back to the jobs doesn't repair it.
https://pastebin.com/jiv13V1T - GEO
EDIT: Your fix did help my problem though! My hero. lol
Good to hear!
GEO.lua explains it! The line "include('Mote-Include.lua')" ends up running a whole bunch of other commands, including this set - which binds all of the f9-f12 key combos with other things. Once you change off GEO, they're all set to unbind at the end.
Code:function global_on_load() send_command('bind f9 gs c cycle OffenseMode') send_command('bind ^f9 gs c cycle HybridMode') send_command('bind !f9 gs c cycle RangedMode') send_command('bind @f9 gs c cycle WeaponskillMode') send_command('bind f10 gs c set DefenseMode Physical') send_command('bind ^f10 gs c cycle PhysicalDefenseMode') send_command('bind !f10 gs c toggle Kiting') send_command('bind f11 gs c set DefenseMode Magical') send_command('bind ^f11 gs c cycle CastingMode') send_command('bind f12 gs c update user') send_command('bind ^f12 gs c cycle IdleMode') send_command('bind !f12 gs c reset DefenseMode') send_command('bind ^- gs c toggle selectnpctargets') send_command('bind ^= gs c cycle pctargetmode') end -- Function to revert binds when unloading. function global_on_unload() send_command('unbind f9') send_command('unbind ^f9') send_command('unbind !f9') send_command('unbind @f9') send_command('unbind f10') send_command('unbind ^f10') send_command('unbind !f10') send_command('unbind f11') send_command('unbind ^f11') send_command('unbind !f11') send_command('unbind f12') send_command('unbind ^f12') send_command('unbind !f12') send_command('unbind ^-') send_command('unbind ^=') end
welp, it worked as pld on protect/shell, but going war/rdm it yields an error. "Attempt to compare nil with number"
that's what I've got right now; windower says the error is from the bolded line.Code:function job_pretarget(spell, action, spellMap, eventArgs) if spell.english:startswith("Protect") or spell.english:startswith("Shell") or spell.english:startswith("Dia") or spell.english:startswith("Fire") or spell.english:startswith("Stone") or spell.english:startswith("Thunder") or spell.english:startswith("Water") or spell.english:startswith("Blizzard") or spell.english:startswith("Bio") or spell.english:startswith("Poison") or spell.english:startswith("Sleep") or spell.english:startswith("Raise") then for _,lvl in pairs({" V"," IV"," III"," II",""}) do --print("current spell checking = "..string.mgsub(spell.english, "%s.+", "")..""..lvl) local spellR = gearswap.res.spells:with('name', string.mgsub(spell.english, "%s.+", "")..""..lvl) if spellR then --print("spellR is good") if spell.english == spellR.en and windower.ffxi.get_spell_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then --print("spell confirmed as casted spell and is good to cast") --print("casted spell = "..spell.english) break elseif 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_spell_recasts()[spellR.recast_id] == 0 and spellR.mp_cost <= player.mp then --print("spell confirmed as new spell and is good to cast = "..spellR.en) eventArgs.cancel = true send_command('input /ma "'..spellR.en..'"'..spell.target.raw) break end end end --print("spell test end") end end
edit: okay, after breaking each condition out into a line, the error is with
so i think it's malfunctioning when it tries to check the spell level for my main job (nil, because warrior can't cast natively) against my actual level.Code:(spellR.levels[player.main_job_id] <= player.main_job_level or
edit2: okay this is bizarre. i tried some stuff, none of it worked, then reverted... the protect part works, but none of the other spells. it's also not handling my pre/midcasts for any of the spells i punch in except protect