Syntax Help: Part 2

Moderator: MacroQuest Developers

Red-One
a ghoul
a ghoul
Posts: 143
Joined: Tue Dec 28, 2004 9:14 pm

Syntax Help: Part 2

Post by Red-One » Fri Jul 08, 2005 8:44 pm

Ok, I have no clue on this one:

Code: Select all

                AddTrigger bf_Chat_tell "@Player@ tells you, '@LinePart@'"
	AddTrigger bf_Chat_tell "@Player@ told you, '@LinePart@'"
	AddTrigger bf_Chat_channel "@Player@ tells ${ChatInChan}:1, '@LinePart@'"
	AddTrigger bf_Chat_irc "<@Player@> @LinePart@

.....

function bf_Chat_channel(string FullLine, string Player, string Command)
{
	;Check it if is a master
	call bf_Check_Master ${Player}
	if ${si_Return}
	{
		return
	}
	echo Received a Channel with ${Command}
	call bf_DoCommand ${FullLine} ${Player} ${Command}
}


......

function bf_DoCommand(string FullLine, string Player, string Command)
{
	echo Start of DoCommand with ${Command}
	;Find the command to execute
	;TODO Custom commands from an XML
	if ${Command.Left[1].Equal["/"]}
	{
		EQExecute ${Command}
	}
	if ${Command.Left[${Me.CleanName.Length}].Equal[${Me.CleanName}]}
	{
		echo Command is for me!
		Command:Set[${Command.Right[${Math.Calc[${Command.Length}-${Me.CleanName.Length}]}]}]
	}
	Switch ${Command}
	{
		case Follow
			echo [COMMAND] follow
			call bf_Follow ${Player}
			break
		case sit
			echo [COMMAND] sit
			call bf_Command_sit
			break
		case stay
			echo [COMMAND] stay
			call bf_Command_stay
			break
		case face
			echo [COMMAND] face
			call bf_Command_face
			break
		Default
			echo Could not parse: ${Command}
			break
			

	}
	EndSwitch

}




ChatInChan is blah and I do a /1 stay
My output is:

Code: Select all

Received a Channel with stay
Start of DoCommand with blah:1
Could not parse blah:1
In the AddTrigger I've also tried %${ChatInChan}% with the same effect.
Any ideas would be grand. :cry:


-Red

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Fri Jul 08, 2005 9:56 pm

Well, you should avoid having to parse tells yourself. Meaning, you know you expect your name at the start of the command in order to determine it's for you. You can do that without parsing it out yourself. Also, if you want the ChatInChan to parse later rather than use the value at the beginning (e.g. you want it dynamic or such), you do need to use %% and because AddTrigger parses immediately, you must either escape the $ at the beginning of the data sequence, or use noparse.

Also, since all of your current triggers use the same basic structure (all give Player and LinePart), you can simply make them use the same function in the first place (it is allowed).

Here's a good example of what your triggers could be:

Code: Select all

AddTrigger bf_Chat "@Player@ tells you, '%\${Me.CleanName}% @LinePart@'"
AddTrigger bf_Chat "@Player@ told you, '%\${Me.CleanName}% @LinePart@'"
AddTrigger bf_Chat "@Player@ tells %\${ChatInChan}%:1, '%\${Me.CleanName}% @LinePart@'"
AddTrigger bf_Chat "<@Player@> %\${Me.CleanName}% @LinePart@
It is really bad to have to parse any of the command yourself, but using a switch as you have done is fine. Also, instead of using a calc to get the length, you can use Command:Set[${Command.Right[-${Me.CleanName.Length}]}] as a shortcut. That may or may not be documented in the LavishScript wiki, but should be and I think it is. But, if you have Blech do the matching of the string for you instead of matching the name yourself, that shouldnt be an issue

Now.. to answer the question. The problem is this:
call bf_DoCommand ${FullLine} ${Player} ${Command}

This command does exactly this:
call bf_DoCommand bob tells blah:1, 'stay' bob stay
The problem, as you should now see clearly, is that you are passing not 3, but 6 parameters to bf_DoCommand. The solution is to use quotes as required by LavishScript syntax (see http://www.lavishsoft.com/wiki/index.ph ... 058;Syntax for the complete command and data sequence syntax rules):
call bf_DoCommand "${FullLine}" "${Player}" "${Command}"
now does this:
call bf_DoCommand "bob tells blah:1, 'stay'" "bob" "stay"
... which correctly passes the values
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:05 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:06 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:07 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:09 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:10 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:11 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:12 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:13 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:14 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:15 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:17 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:18 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Syntax Help: Part 2

Post by xyilla » Sat May 31, 2025 7:54 am