Jump to content


Photo

Check for spell or ability


    4 replies to this topic

    #1 tdk1069

    tdk1069

      Member

    • Members
    • PipPip
    • 25 posts

      Posted 19 October 2014 - 11:19 AM

      Hiya,

      How can i uses the Resources to check if a given string exists in the spell or abilities list? 

       

      I tried using res.job_abilities:with('name',"Flash") and checking for nil but it throws an error rather than nil. I was going to build a table of all the names, but it seems silly when the resources are there already (im obviously missing something)

       

      Forgive my newbieness :) and thanks



      #2 sdahlka

      sdahlka

        Advanced Member

      • Members
      • PipPipPip
      • 324 posts

        Posted 19 October 2014 - 12:47 PM

        windower.ffxi.get_abilities()

        Returns a table contain 4 sub-tables:

        {
        job_abilities: {...}
        job_traits: {...}
        weapon_skills: {...}
        pet_commands: {...}
        }

        Each sub-table lists the job abilities, job traits, weapon_skills or pet_commands the current character has available. This will include job abilities and pet commands that are simply waiting on their recast timer, as long as it appears in the respective menu.

         

        windower.ffxi.get_spells()

        Returns a table containing all learned spells. Table is indexed by spell ID and contains a boolean for whether or not the player knows the spell. This does not indicate that the spell can be cast by the current job, just that it is known.



        #3 tdk1069

        tdk1069

          Member

        • Members
        • PipPip
        • 25 posts

          Posted 19 October 2014 - 01:00 PM

          Sorry guess i muddled how i wrote the question :) . What I was hoping for was a easy way to determine if a string was the name of a Spell, Job ability, or not found. If no easy way, i'll just Iterate the lists and build a table of flags.



          #4 Arcon

          Arcon

            Advanced Member

          • Windower Staff
          • 1189 posts
          • LocationMunich, Germany

          Posted 19 October 2014 - 01:25 PM

          I assume you entered the line (res.job_abilities:with('name',"Flash")) into the chatlog or console? If so, that will fail, but otherwise that works. However, Flash is a spell, not a JA, so this will obviously be nil.

           

          //eval print(res.spells:with('name', 'Flash')

           

          This will print out the table entry and its index (spell ID in this case). However, this will not work:

           

          //eval print(res.spells:with('name', "Flash")

           

          The reason for that is the double quote. Windower basically removes double quotes, because they are used to group arguments together. You either need to use single quotes like above or escape them like so:

           

          //eval print(res.spells:with('name', \"Flash\")

           

          But again, this is only an issue for the chatlog or console. In a Lua file both single and double quotes will work just the same.



          #5 tdk1069

          tdk1069

            Member

          • Members
          • PipPip
          • 25 posts

            Posted 19 October 2014 - 05:07 PM

            Thanks, I was in lua, was playing with some ideas and timers, and was trying to split out ja recast_id from spell.id's as I didn't realise there was a recast_id originally for JAs, and was getting wrong times as checking the wrong id and nil in the wrong place.

             

            Thanks for the reply :)






            1 user(s) are reading this topic

            0 members, 1 guests, 0 anonymous users