Jump to content


Photo

'catch-all' gearswap script for spells?


Best Answer Gukai , 23 October 2014 - 03:13 PM

Thank you!  the lua loaded, now i just need to find a chance to properly test it  :)

Go to the full post


    6 replies to this topic

    #1 Gukai

    Gukai

      Advanced Member

    • Members
    • PipPipPip
    • 95 posts

      Posted 22 October 2014 - 10:33 PM

      Hi

      I was wondering if this coding could be use as a catch-all for the midcast of magic spells, specifically lines 6-7.  

       

      However I also want to ask if lines 4-5 will work with the grouping of " 'Protect' or 'Shell' ", or if i need to break them into 2 rules.

       

      	if spell.type:endswith('Magic') then
      		if sets.midcast[spell.english] then
      			equip(sets.midcast[spell.english])
      		elseif string.find(spell.english,'Protect' or 'Shell') then
      			equip(sets.midcast.ProtectShell)
      		elseif spell.skill[spell.english] then
      			equip(sets.midcast[skill.english])
      

      So let me say, that I think lines 6-7 will work but it's dependent upon how you have your sets set up.  I have sets that are oriented towards the magic type, such as:

      sets.midcast['Enhancing Magic'] = {   

      This is why I think it will work, however I may have some of the terminology wrong.  I figured if we can do sets.midcast[spell.english] then why not skills, as long as the sets.midcast are named like I have above.

       

      Please let me know, this would save me some time :)

       



      #2 sdahlka

      sdahlka

        Advanced Member

      • Members
      • PipPipPip
      • 324 posts

        Posted 23 October 2014 - 12:07 AM

        Hi

        I was wondering if this coding could be use as a catch-all for the midcast of magic spells, specifically lines 6-7.  

         

        However I also want to ask if lines 4-5 will work with the grouping of " 'Protect' or 'Shell' ", or if i need to break them into 2 rules.

         


        	if spell.type:endswith('Magic') then
        		if sets.midcast[spell.english] then
        			equip(sets.midcast[spell.english])
        		elseif string.find(spell.english,'Protect' or 'Shell') then
        			equip(sets.midcast.ProtectShell)
        		elseif spell.skill[spell.english] then
        			equip(sets.midcast[skill.english])
        

        So let me say, that I think lines 6-7 will work but it's dependent upon how you have your sets set up.  I have sets that are oriented towards the magic type, such as:

        sets.midcast['Enhancing Magic'] = {   

        This is why I think it will work, however I may have some of the terminology wrong.  I figured if we can do sets.midcast[spell.english] then why not skills, as long as the sets.midcast are named like I have above.

         

        Please let me know, this would save me some time :)

         

        i would do it like this

         

            if spell.action_type == 'Magic' then
                if windower.wc_match(spell.english, 'Protect*|Shell*') then
                    equip(sets.midcast.ProtectShell)
                elseif sets.midcast[spell.english] then
                    equip(sets.midcast[skill.english])
                end
            end
         

        how ever you would have to label your sets for each spell

        i.e. for cure III

        sets.midcast['Cure III']



        #3 Arcon

        Arcon

          Advanced Member

        • Windower Staff
        • 1189 posts
        • LocationMunich, Germany

        Posted 23 October 2014 - 05:31 AM

        if spell.type:endswith('Magic') then
        		if sets.midcast[spell.english] then
        			equip(sets.midcast[spell.english])
        		elseif string.find(spell.english,'Protect' or 'Shell') then
        			equip(sets.midcast.ProtectShell)
        		elseif spell.skill[spell.english] then
        			equip(sets.midcast[skill.english])

         

        Like sdahlka said, I'd replace spell.type:endwith('Magic') with spell.action_type == 'Magic'. This is faster and more accurate.

         

        Also, "string.find(spell.english, 'Protect' or 'Shell')" will not work. the correct way to do this would be to move the "or" outside:

         

        string.find(spell.english, 'Protect') or string.find(spell.english, 'Shell')

         

        But I'd recommend it either this way (which is equivalent to the above):

         

        spell.english:find('Protect') or spell.english:find('Shell')

         

        Or, preferably, use match instead of find:
         

        spell.english:match('Protect') or spell.english:match('Shell')

         

        If you want the little bit of extra performance, you can use "string.startswith" instead of "string.match" (because string.match does pattern matching by default):

         

        spell.english:startswith('Protect') or spell.english:startswith('Shell')

         

        Any of these will be faster than using windower.wc_match, although that allows you to write it in one expression.

         

        Finally, I'm not sure what line 6 is supposed to do. spell.skill should either be a number or a string, so using [] on it doesn't seem to make much sense.



        #4 Gukai

        Gukai

          Advanced Member

        • Members
        • PipPipPip
        • 95 posts

          Posted 23 October 2014 - 07:35 AM

          Hi Arcon, thanks for your help once again.  Let me explain what line 6 is supposed to do, or rather... what I'm trying to do.

           

          Here are the names of my sets:

          sets.midcast['Healing Magic']

          sets.midcast['Enhancing Magic']

          sets.midcast['Dark Magic']

          sets.midcast['Elemental Magic']

          sets.midcast['Divine Magic']

           

          so the set 'name' is the skill type (at least I think it's defined as a 'skill', it could be called something else, please let me know otherwise)

           

          I could make a rule for each...  if spell.skill=='ElementalMagic' then (blah blah blah).   I was hoping to simplify it.  I was trying to something similar to this rule:

          	if sets.midcast[spell.english] then
          		equip(sets.midcast[spell.english])
          

          Except instead of telling it to look for a specific spell being casted, look for the spell type.  so if its an elemental magic spell, equip the gear set called 'Elemental Magic'.  As long as the set name matches the skill, I was hoping it would work.  Of course, if you named your set 'BigNuke', then it wouldnt work, haha.



          #5 Gukai

          Gukai

            Advanced Member

          • Members
          • PipPipPip
          • 95 posts

            Posted 23 October 2014 - 07:38 AM

            Hey Arcon, on a side note, semi related to what you instructed regarding the protect/shell...

            if string.find(spell.english,'Utsusemi') then
            			if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)']) then -- Cancel Copy Image 1 & 2 For Utsusemi: Ichi --
            				send_command('@wait 1.7;cancel Copy Image*')
            

            This code isnt working when i have 1-2 shadows from Utsusemi Ni active and I try to cast Ichi... the shadows dont cancel.  Could this be a result of using the string.find command?  You told me not to use it for protect/shell, I'm wondering if I should apply your advice to this utsusemi rule.  Sorry for the side question, it's sorta related  :P



            #6 Arcon

            Arcon

              Advanced Member

            • Windower Staff
            • 1189 posts
            • LocationMunich, Germany

            Posted 23 October 2014 - 07:56 AM

             

            Hi Arcon, thanks for your help once again.  Let me explain what line 6 is supposed to do, or rather... what I'm trying to do.

             

            Here are the names of my sets:

            sets.midcast['Healing Magic']

            sets.midcast['Enhancing Magic']

            sets.midcast['Dark Magic']

            sets.midcast['Elemental Magic']

            sets.midcast['Divine Magic']

             

            so the set 'name' is the skill type (at least I think it's defined as a 'skill', it could be called something else, please let me know otherwise)

             

            I could make a rule for each...  if spell.skill=='ElementalMagic' then (blah blah blah).   I was hoping to simplify it.  I was trying to something similar to this rule:

               if sets.midcast[spell.english] then
                    equip(sets.midcast[spell.english])

            Except instead of telling it to look for a specific spell being casted, look for the spell type.  so if its an elemental magic spell, equip the gear set called 'Elemental Magic'.  As long as the set name matches the skill, I was hoping it would work.  Of course, if you named your set 'BigNuke', then it wouldnt work, haha.

             

            In that case, you'll want this:
             

            elseif sets.midcast[spell.skill] then
                equip(sets.midcast[spell.skill])
            end

             

            Hey Arcon, on a side note, semi related to what you instructed regarding the protect/shell...

            if string.find(spell.english,'Utsusemi') then
            			if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)']) then -- Cancel Copy Image 1 & 2 For Utsusemi: Ichi --
            				send_command('@wait 1.7;cancel Copy Image*')
            

            This code isnt working when i have 1-2 shadows from Utsusemi Ni active and I try to cast Ichi... the shadows dont cancel.  Could this be a result of using the string.find command?  You told me not to use it for protect/shell, I'm wondering if I should apply your advice to this utsusemi rule.  Sorry for the side question, it's sorta related   :P

             

            I cannot see why this wouldn't work. Looks perfectly fine for me. It's not that string.find is bugged or anything, it's just not the right tool for the job. You should only use string.find if you need the specific start and end indices of a substring, which you don't here. windower.wc_match would be the ideal function to call, while string.startswith would would be the most efficient function to call (windower.wc_match can be rather expensive).



            #7 Gukai

            Gukai

              Advanced Member

            • Members
            • PipPipPip
            • 95 posts

              Posted 23 October 2014 - 03:13 PM   Best Answer

              Thank you!  the lua loaded, now i just need to find a chance to properly test it  :)






              1 user(s) are reading this topic

              0 members, 1 guests, 0 anonymous users