Page 1 of 1

need some coding help

Posted: Mon Mar 28, 2011 9:37 pm
by lisa
Ok I just can't work out how I am going to do this bit.

Basically I am setting a bot to follow a party member if the name matches one set in profile. Looks like this atm.

Code: Select all

  		if ( settings.profile.options.PARTY_FOLLOW_NAME ) then 
  		if GetPartyMemberName(1) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party1');");  end
		if GetPartyMemberName(2) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party2');");  end
		if GetPartyMemberName(3) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party3');");  end
		if GetPartyMemberName(4) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party4');");  end
		if GetPartyMemberName(5) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party5');");  end
		else RoMScript("FollowUnit('party1');");		

		end
Which works aslong as if their is a name in profile and it matches one of the party member names. Trouble is what if you put in a wrong name or spell it wrong? At the moment it follow no one.
I tried to just add in

Code: Select all

  		if ( settings.profile.options.PARTY_FOLLOW_NAME ) then
  		RoMScript("FollowUnit('party1');");
but it starts to follow party1 and then if name is right it starts to follow correct party member and does it back and forth non stop.
I guess I need to add a check if it is following after the member names and then if not make it follow party 1.

I am a bit tired so seeing if anyone else has an easy solution that I just can't think of lol

Re: need some coding help

Posted: Mon Mar 28, 2011 9:43 pm
by lisa
lol nvm it just hit me

Code: Select all

	while (true) do	
  		if ( settings.profile.options.PARTY_FOLLOW_NAME ) then
  		if GetPartyMemberName(1) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party1');"); break  end
		if GetPartyMemberName(2) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party2');"); break  end
		if GetPartyMemberName(3) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party3');"); break  end
		if GetPartyMemberName(4) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party4');"); break  end
		if GetPartyMemberName(5) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party5');"); break  end
		RoMScript("FollowUnit('party1');");
		else RoMScript("FollowUnit('party1');");		

		end
break
	end

Re: need some coding help

Posted: Tue Mar 29, 2011 12:02 am
by JackBlonder

Code: Select all

if...
if...
if...
Every if is getting checked.

Code: Select all

if...
elseif...
elseif...
The second if is only checked, when the first fails.

Re: need some coding help

Posted: Tue Mar 29, 2011 2:20 am
by lisa
so more like this

Code: Select all

  		if ( settings.profile.options.PARTY_FOLLOW_NAME ) then
    		if GetPartyMemberName(1) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party1');"); 
			elseif GetPartyMemberName(2) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party2');");
			elseif GetPartyMemberName(3) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party3');");
			elseif GetPartyMemberName(4) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party4');");
			elseif GetPartyMemberName(5) == settings.profile.options.PARTY_FOLLOW_NAME  then RoMScript("FollowUnit('party5');");
			else RoMScript("FollowUnit('party1');"); end
		
		else RoMScript("FollowUnit('party1');");		

		end