Key Bind Not Working Properly

Language: JP EN DE FR
New Items
2018-08-14
105 users online
Forum » Windower » Support » Key bind not working properly
Key bind not working properly
Offline
Posts: 163
By Zyla 2018-03-26 21:08:29
Link | Quote | Reply
 
I'm having a problem with my gearswap binds, in the form of my binding for Spectral Jig isn't working. It's still trying to use a Silent Oil when I have DNC as my subjob. Everything else seems to work, even though Utsusemi: Ni and Ichi also seem to be tied to the WIN+. and WIN+, for some random reason. As you can probably tell I'm still really new to this. The following is taken from Arislan's gearswap lua, and I modified it a bit to add in function for DNC and NIN subjobs, amongst a few other additions. Any idea why the Spectral Jig binding isn't working? Thnx in advance.



if player.sub_job == "RDM" then
send_command('bind !r input /ma "Refresh" <stpc>')
send_command('bind !y input /ma "Phalanx" <me>')
send_command('bind !u input /ma "Stoneskin" <me>')
send_command('bind !. input /ma "Sneak" <me>')
send_command('bind !, input /ma "Invisible" <me>')
else
send_command('bind !r input /ma "Battery Charge" <me>')
send_command('bind !y input /ma "Barrier Tusk" <me>')
send_command('bind !u input /ma "Diamondhide" <me>')
send_command('bind !. input /item "Silent Oil" <me>')
send_command('bind !, input /item "Prism Powder" <me>')
end

send_command('bind @c gs c toggle CP')

if player.sub_job == "DNC" then
send_command('bind !. input /ja "Spectral Jig" <me>')
else
send_command('bind !. input /item "Silent Oil" <me>')
send_command('bind !, input /item "Prism Powder" <me>')
end

if player.sub_job == "NIN" then
send_command('bind !. input /ma "Monomi: Ichi" <me>')
send_command('bind !, input /ma "Tonko: Ni" <me>')
send_command('bind ^. input /ma "Utsusemi: Ichi" <me>')
send_command('bind ^, input /ma "Utsusemi: Ni" <me>')
else
send_command('bind !. input /item "Silent Oil" <me>')
send_command('bind !, input /item "Prism Powder" <me>')
end

if player.sub_job == 'WAR' then
send_command('bind ^numpad/ input /ja "Berserk" <me>')
send_command('bind ^numpad* input /ja "Warcry" <me>')
send_command('bind ^numpad- input /ja "Aggressor" <me>')
end
 Shiva.Arislan
Offline
Server: Shiva
Game: FFXI
user: Arislan
Posts: 615
By Shiva.Arislan 2018-03-26 21:45:46
Link | Quote | Reply
 
It's detecting that your sub is DNC, binds Spectral Jig, but the subsequent if/else statements overwrite that w/ Powder/Oil. Use elseif in one continuous statement for the desired result:
Code
if player.sub_job == "RDM" then 
    send_command('bind !r input /ma "Refresh" <stpc>')
    send_command('bind !y input /ma "Phalanx" <me>')
    send_command('bind !u input /ma "Stoneskin" <me>')
    send_command('bind !. input /ma "Sneak" <me>')
    send_command('bind !, input /ma "Invisible" <me>')
elseif player.sub_job == "DNC" then 
    send_command('bind !. input /ja "Spectral Jig" <me>')
elseif player.sub_job == "NIN" then 
    send_command('bind !. input /ma "Monomi: Ichi" <me>')
    send_command('bind !, input /ma "Tonko: Ni" <me>')
    send_command('bind ^. input /ma "Utsusemi: Ichi" <me>')
    send_command('bind ^, input /ma "Utsusemi: Ni" <me>')
elseif player.sub_job == 'WAR' then
    send_command('bind ^numpad/ input /ja "Berserk" <me>')
    send_command('bind ^numpad* input /ja "Warcry" <me>')
    send_command('bind ^numpad- input /ja "Aggressor" <me>')
else
    send_command('bind !r input /ma "Battery Charge" <me>')
    send_command('bind !y input /ma "Barrier Tusk" <me>')
    send_command('bind !u input /ma "Diamondhide" <me>')
    send_command('bind !. input /item "Silent Oil" <me>')
    send_command('bind !, input /item "Prism Powder" <me>')
end

send_command('bind @c gs c toggle CP')
[+]
 Ragnarok.Martel
Offline
Server: Ragnarok
Game: FFXI
Posts: 1960
By Ragnarok.Martel 2018-03-26 21:46:43
Link | Quote | Reply
 
I'm gonna say probably because the way you have this setup allows redundant code to run.

Let's say you're /dnc. Here's how the logic will flow.

First the RDM rule is checked, and fails, then the else passes because the above rule failed. Then the /dnc rule is checked and passes. jig is bound. The else after it fails since the above if passed.

Now the key point. The /nin rule is checked and fails since you're not /nin.. but the else after it passes, and rebinds silent oil over your jig bind.

Only one of these sets of rules should be allowed to run, as it's only possibly to have one sub at any given time. But it's being run as multiple fully independent checks. Allowing later checks to overwrite earlier ones.

Perhaps something like this?
Code
if player.sub_job == "RDM" then
	send_command('bind !r input /ma "Refresh" <stpc>')
	send_command('bind !y input /ma "Phalanx" <me>')
	send_command('bind !u input /ma "Stoneskin" <me>')
	send_command('bind !. input /ma "Sneak" <me>')
	send_command('bind !, input /ma "Invisible" <me>')
elseif player.sub_job == "BLU" then
	send_command('bind !r input /ma "Battery Charge" <me>')
	send_command('bind !y input /ma "Barrier Tusk" <me>')
	send_command('bind !u input /ma "Diamondhide" <me>')
	send_command('bind !. input /item "Silent Oil" <me>')
	send_command('bind !, input /item "Prism Powder" <me>')
elseif player.sub_job == "DNC" then
	send_command('bind !. input /ja "Spectral Jig" <me>')
elseif player.sub_job == "NIN" then
	send_command('bind !. input /ma "Monomi: Ichi" <me>')
	send_command('bind !, input /ma "Tonko: Ni" <me>')
	send_command('bind ^. input /ma "Utsusemi: Ichi" <me>')
	send_command('bind ^, input /ma "Utsusemi: Ni" <me>')
elseif player.sub_job == 'WAR' then
	send_command('bind ^numpad/ input /ja "Berserk" <me>')
	send_command('bind ^numpad* input /ja "Warcry" <me>')
	send_command('bind ^numpad- input /ja "Aggressor" <me>')
	send_command('bind !. input /item "Silent Oil" <me>')
	send_command('bind !, input /item "Prism Powder" <me>')
else
	send_command('bind !. input /item "Silent Oil" <me>')
	send_command('bind !, input /item "Prism Powder" <me>')
end

send_command('bind @c gs c toggle CP')

Chaining elseifs like this makes certain that only one of these possibilities can activate at a time, and if none of them pass, then you default to oil/powder binds.
[+]
Offline
Posts: 163
By Zyla 2018-03-27 02:37:37
Link | Quote | Reply
 
Oh I see, that makes perfect sense now. Clearly as you can see I'm new to modifying gearswap code, but that explanation made it click in my head. My thanks to both of you ^^
Log in to post.