FFXIAH.com

Language: JP EN DE FR
New Items
2023-11-19
users online
Gearswap_Academia_4
Class #4

Master thread



Last one was a bit heavy! I hope you took your time with it. Because we'll use what we learn in Class #3 for this one. We'll take a look at adding JA and WS sets, as well as including our TP meleeing sets!

So far we should be here now: https://pastebin.com/ukFQZapf

Let's take some time to review what we've learn so far (you can go check the previous lessons too if you don't remember)

We learned how to make a new gearset. I want to add a few new categories to the sets up top in the get_sets() function, you can add these ones with the other categories we left empty.
Code
	sets.melee = {}
	sets.ws = {}
	sets.ja = {}


so the new full list of sets tables should look like this:
Code
sets.idle = {}                  -- Leave this empty
sets.melee = {}					-- Leave this empty
sets.ws = {}					-- Leave this empty
sets.ja = {}					-- Leave this empty
sets.precast = {}               -- leave this empty    
sets.midcast = {}               -- leave this empty    
sets.aftercast = {}             -- leave this empty


Now that we have our new tables, we can start using them. So use what you have learned in the previous classes and go ahead and make the following sets with the proper gear you'd like in side of them: (Hint: Class #1)

sets.ws.fastblade
sets.ja.provoke
sets.melee.normal

Lesson 8 - Handling JA and WS.

I am pretty sure you can guess what those sets will be used for. So first we'll start reviewing the Class #2 and Class #3 stuff, just to make sure you really get it. So I'm going to ask you to create rules in the precast (no cast time stuff like JA and WS goes in precast) for Provoke, via it's name. So like we first used spell.name == "Cure" now instead we can use spell.name == "Provoke".

Try to make that rule yourself before checking in the answer in the spoiler below. Note: This time you'll have to get around the already there equip of the fast cast set using the "else". You can refer to the midcast function we wrote it should ring a few bells!

If you get this, that's ok:

But this isn't quite right, it'll function ok for Provoke, but if we do anything that isn't provoke, then it'll put us in the fast cast set. So to cover our bases better, we'll have to also create a condition for actual magic that needs the fast cast set. We can use the nifty thing that is "elseif". Elseif lets you make a else condition (if the previous one was false) while also adding one (or more) conditions to it. So doing this:

Would work better but while we tried to catch every type of magic there is, we could simply go with the when its not a JA nor a WS and code less stuff. Also, since we are going to check for if it is NOT a JA, then why not do that first. Our final precast function adding the rule to properly handle the fast cast set as well as the provoke check would look like this:

The above code reads as if my spell is provoke then equip the provoke set or else check if my spell is NOT a JA (notice the use of ~= ) then equip the fast cast set. You can go ahead are reload your lua (//gs r) and go provoke a rabbit. Once again, //gs showswaps and you should see the voke set getting equip as expected.

That should cover all our bases... oh wait what about Weapon Skills? Those are not JA, and not Provoke, therefore the above code will have you use a WS in the fast cast set... Hmm that's not so good. So in order to make sure we do something that does not require a lot of if-then-else for everything we could possibly do we'll have to introduce a new concept in our sets, and change a bit the precast function. First we'll remove the provoke rule we just did. I know... I know... Make sure to turn the elseif into a simple if now that we removed the provoke part.

Lesson 9 - Using a catch all for unique sets.

So right now, our precast function only check to make sure we don't equip fast cast if we use a JA. You can reload the lua and try using any JA and you should see no swap happening. Awesome. So now we're going to go and change the names of both the Provoke and the Fast Blade gear sets:

They were:
sets.ws.fastblade
sets.ja.provoke

Rename them to:
sets.ws['Fast Blade']
sets.ja['Provoke']

The reason we do this is because, remember when we said spell.name is a variable? And that the type of it is string? Well, when we put something in between ' ' or " " it means that is a string. If you have the lua syntax in your text editor it should color it in a color shared by all string type of stuff. For example, the name of a piece of gear in one of your set is a string, that's why we put it between quotations. So back to our set names, what sets.ws['Fast Blade'] does over sets.ws.fastblade is that the 'Fast Blade' table inside the sets.ws table is now named with a string. And as we learned in Class #3 and just above with the provoke rule we removed, we can make if conditions with a string. But we can go even further. When we name a set with a string like this, we can create a catch all rule! It's like magic. Remember, when I use Provoke. the spell.name variable we keep using will be equal to 'Provoke'. When I use 'Cure' the spell.name will be equal to 'Cure'. When I use Fast Blade, the spell.name variable will be equal to 'Fast Blade'... That's very similar to what I put between the [Brackets] isn't it?

So if 'Provoke' is the same thing as spell.name when I use provoke I can to this:
Code
    if sets.ja[spell.name] then
        equip(sets.ja[spell.name])        
    end


This literally means that if there is a sets.ja that exist with my JA's name then it will equip that set. We can do the same exact thing for the WS ones:
Code
    if sets.ws[spell.name] then
        equip(sets.ws[spell.name])        
    end


Like I said, it's like magic! Now you can add any sets.ja['Whatever JA Name'] and it will work, without having to change anything in the precast function. Same for WS sets.

So the finished precast function with that can handle WS and JA and our casting base fast cast set would look like this:

And from there you could simply add as many WS and JA sets using that form of naming in your top get_sets() function and they will work as expected. Go and try to add some, do reload your lua (//gs r) and turn the showswaps on, I think you know how by now.

Next class, we'll dig into idle vs engaged sets, TP and DT sets and how to make rules for them. See ya in class 5.

Turtles.

Author: Elizabet
Date Created: 2020-01-21 19:27:29
Date Last Modified: 2020-01-21 21:41:55
Updates: 13
Bytes: 8037