Gearswap Midcast Malfunction

Language: JP EN DE FR
New Items
2023-11-19
users online
Forum » Windower » Support » Gearswap midcast malfunction
Gearswap midcast malfunction
Offline
Posts: 5
By Dyrandal 2016-10-25 21:33:27
Link | Quote | Reply
 
Hey everyone, first post here. I'm working on a lua file and for some reason the midcast function seems to be constantly giving me problems.

First, here's the code block:
Code
function midcast(spell,action)

----------------------------
--Weaponskills & Abilities--
----------------------------
		if spell.action_type == 'Ability' then
			return
		end
		
---------
--Magic--
---------
		if spell.action_type == 'Magic' then
		
	----------
	--Enmity--
	----------
		
			if spell.english == 'Flash' or 'Foil' then
					equip(sets.Utility.Enmity)
					return
			end
			if spell.english == 'Jettatura' or 'Blank Gaze' or 'Magnetite Cloud' or 'Sheep Song' then
					equip(sets.Utility.Enmity)
					return
			end
		
	-------------
	--Enhancing--
	-------------
		
			if spell.english:startswith('Regen') then
					equip(sets.Utility.EnhancingDuration, sets.Utility.Regen)
					return
			end		
			if spell.english:startswith('Bar') then
					equip(sets.Utility.EnhancingDuration, sets.Utility.EnhancingSkill)
					return
			end		
			if spell.english == 'Temper' or 'Crusade' or spell.english == 'Aquaveil' then
					equip(sets.Utility.EnhancingDuration, sets.Utility.EnhancingSkill)
					return
			end		
			if spell.english == 'Blaze Spikes' or 'Ice Spikes' or 'Shock Spikes' then
					equip(sets.Utility.EnhancingDuration, sets.Utility.EnhancingSkill)
					return
			end		
			if spell.english == 'Stoneskin' then
					equip(sets.Utility.EnhancingDuration, sets.Utility.Stoneskin)
                    return
			end		
			if spell.english == 'Refresh' then
					equip(sets.Utility.EnhancingDuration, sets.Utility.Refresh)
					return
			end			
			if spell.english == 'Phalanx' then
					equip(sets.Utility.EnhancingDuration, sets.Utility.EnhancingSkill, sets.Utility.Phalanx)
					return
			end
		
	------------
	--Ninjutsu--
	------------
		
			if spell.english == 'Utsusemi: Ichi' then
                equip(sets.Utility.Ninjutsu)
				return
			end

	--------------
	--Blue Magic--
	--------------
		
			if spell.english == 'Pollen' or 'Wild Carrot' or 'Healing Breeze' then
					equip(sets.Utility.Cure)
					return
			end		
			if spell.english == 'Cocoon' then
					equip(sets.Utility.Defense)
					return
			end
			else
				send_command('@input /echo Reached end of the statement.')		
				return			
		end
		

end		


The first issue I had was midcast equipping my enmity sets immediately after precast sets for weaponskills, thus ruining them. I added that return if statement for abilities and that seemed to fix it.

The second issue was that it was mixing up midcast sets for spells. I added return statements to them all and that seemed to fix it.

My current issue is that it doesn't seem to pass the enmity spell set statement (first spell statements). So it just equips that for every scenario. I've tried using multiple different syntaxes with no success and have double checked spellings. I've tried using ifelse statements as well with no success, so not sure if I'm missing something or what's going on.

Any help is appreciated.
 Ragnarok.Flippant
Offline
Server: Ragnarok
Game: FFXI
user: Enceladus
Posts: 658
By Ragnarok.Flippant 2016-10-25 22:55:57
Link | Quote | Reply
 
Code
if spell.english == 'Flash' or 'Foil' then

You can't write what you mean to say like this. You're giving two conditions, but the second condition is literally just asking "if 'Foil' is not false and not nil," and a string is neither, so it will always be true.

Has to be
Code
if spell.english == 'Flash' or spell.english == 'Foil' then

or you can use Windower's Set object to help reduce the length
Code
if S{"Flash","Foil"}:contains(spell.english) then

This has likely been causing you an issue the whole time; you should go back to using elseif's and not returns, as it's a bit short-sighted.
Offline
Posts: 5
By Dyrandal 2016-10-26 00:21:19
Link | Quote | Reply
 
Wow, thanks so much!!, that was definitely the case.

I'll work on cleaning it up now. That bit you mentioned with windower's Set object, would that be the entire syntax?
Log in to post.