1) Those two functions are, in fact, doing basically the same thing, but for entirely different reasons. Engaging a mob is in no way whatsoever an 'aftercast' event; it is not the result of you completing an action (spell, ability, etc). Therefore those two functions are not and should not be considered the same. Just because they happen to share the same code in your particular example doesn't mean that they will or must always share the same code.
However if you consider it redundant code, that's because it is. Two separate events are each executing the same code logic. It -should- be refactored into having those two functions call a third function, like so:
I never write that out in the little example solutions I give because it's a more advanced methodology, and people have a hard enough time understanding the basics as it is. Ultimately, I have to either explain why the two functions use redundant code, or why I'm adding an entirely new function just to do some small bit of logic (which also means explaining code flow and similar topics). If you don't even understand enough to ask the right questions, I'm going with the simpler version.Code:function aftercast(spell) equip_gear() end function status_change(new_status, old_status) equip_gear() end function equip_gear() if player.status=='Engaged' then equip(sets.TP[TP_Set_Names[TP_Index]]) else equip(sets.Idle[Idle_Set_Names[Idle_Index]]) end end
This is not true.in spellcast you only needed one thing to put tp equip ment on when you engaged and after casting a spell/using a JA,WS
That's one 'instruction', but it's not one 'thing'. You have to explicitly note that you're equipping the same set for both engaging an enemy and on aftercast. It's also broken, because it will equip your TP set on aftercast if you're idle. So you in fact need to start adding in conditionals to check your status so that aftercast equips the correct set based on your status. Eventually you end up with enough instructions that it doesn't look that much different from the lua version.Code:<equip when="aftercast|engaged" set="TP" />
I tend to be more explicit in my parameter names (new_status and old_status), but frankly, what explanation is needed? Your status changed; here's the new one, this was the old one.And i would see new and old on status change with out any explanation
Pretarget was added because of a specific need: the ability to change the target used by the original command entry. It allows one to take "/ma cure <t>" and change it to "/ma cure <stpc>" or "/ma cure <stpt>", etc., and functionally allow the user to get that targetting arrow for selecting who they want to cast on.jsut like i dont exactly understand the purpose of pretarget coding cause it sounds like the same as precast to me.
Byrth originally didn't want to add it, but ultimately it was impractical to do something like that without adding an extra event phase. At the point in time when GearSwap is calling precast(), you've already passed the phase where the selection arrow was used. If you wanted to change <stpc> to <stpt> in the precast function, you'd end up having to manually select a target twice, which is just stupid.
The vast majority of people should never need to touch pretarget(), and that should be sort of implied in the event name: pre-"target". If you're not messing with the targetting, you don't need to be using that function.
XI Wiki


