New features: While with multiple parameters

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

Message
Author
Kaspy
Halfway to Eternity
Halfway to Eternity
Posts: 398
Joined: 08 Jun 2012, 15:42
Noob?: No
Location: Brazil

New features: While with multiple parameters

#1 Post by Kaspy »

Now while allows multiple parameters in the same way that if/elsif/else

Image


r8859
Image

kangtuji
Noob
Noob
Posts: 7
Joined: 19 May 2010, 09:17
Noob?: No

Re: New features: While with multiple parameters

#2 Post by kangtuji »

So... replace the whole block

Code: Select all

	##########################################
	# while statement: while (foo <= bar) as label
	} elsif ($line =~ /^while\s/) {
		my ($first, $cond, $last, $label) = $line =~ /^while\s+\(\s*"?(.*?)"?\s+([<>=!]+?)\s+"?(.*?)"?\s*\)\s+as\s+(.*)/;
		if (!defined $first || !defined $cond || !defined $last || !defined $label) {$self->{error} = "$errtpl: syntax error in while statement"}
		else {
			my $pfirst = parseCmd($first, $self); my $plast = parseCmd($last, $self);
			if (defined $self->{error}) {$self->{error} = "$errtpl: $self->{error}"; return}
			unless (defined $pfirst && defined $plast) {$self->{error} = "$errtpl: either '$first' or '$last' has failed"}
			elsif (!cmpr($pfirst, $cond, $plast)) {$self->{line} = $self->{label}->{"end ".$label}}
			$self->{line}++
		}
		$self->{timeout} = 0
	##########################################
with new code

Code: Select all


 	##########################################
 	# while statement: while (foo <= bar) as label
 	} elsif ($line =~ /^while\s/) {
-		my ($first, $cond, $last, $label) = $line =~ /^while\s+\(\s*"?(.*?)"?\s+([<>=!]+?)\s+"?(.*?)"?\s*\)\s+as\s+(.*)/;
-		if (!defined $first || !defined $cond || !defined $last || !defined $label) {$self->{error} = "$errtpl: syntax error in while statement"}
-		else {
-			my $pfirst = parseCmd($first, $self); my $plast = parseCmd($last, $self);
-			if (defined $self->{error}) {$self->{error} = "$errtpl: $self->{error}"; return}
-			unless (defined $pfirst && defined $plast) {$self->{error} = "$errtpl: either '$first' or '$last' has failed"}
-			elsif (!cmpr($pfirst, $cond, $plast)) {$self->{line} = $self->{label}->{"end ".$label}}
-			$self->{line}++
-		}
+		my ($text, $label) = $line =~ /^while\s+\(\s*(.*)\s*\)\s+as\s+(.*)/;
+		my $text = parseCmd($text, $self);
+		if (defined $self->{error}) {$self->{error} = "$errtpl: $self->{error}"; return}
+		my $savetxt = particle($text, $self, $errtpl);
+		if (!multi($savetxt, $self, $errtpl)) {
+			$self->{line} = $self->{label}->{"end ".$label};
+		}
+		$self->{line}++;
 		$self->{timeout} = 0
 	##########################################
 	# pop value from variable: $var = [$list]
Or should I replace all that - lines with + lines ?
Sorry, never update throught the web before, after all those times, I still need lot learning ...

Image

On other unrelated note,
Did the macro already support "multiple class" that threated as OR ?

Kaspy
Halfway to Eternity
Halfway to Eternity
Posts: 398
Joined: 08 Jun 2012, 15:42
Noob?: No
Location: Brazil

Re: New features: While with multiple parameters

#3 Post by Kaspy »

Use SVN: http://openkore.com/index.php/TortoiseSVN_Guide

I do not understand the second question
Image

c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: New features: While with multiple parameters

#4 Post by c4c1n6kr3m1 »

ente ngapain bro, tinggal download aja susah susah.
replace (-)line with (+)line
for every job except novice you can use this

Code: Select all

eval $::char->{jobID} > 0
for swordman = 1, Merchant = 5 ( look inside src\globals.pm ), you can use this way

Code: Select all

eval $::char->{jobID} =~ /^1|5$/
i guess...

kangtuji
Noob
Noob
Posts: 7
Joined: 19 May 2010, 09:17
Noob?: No

Re: New features: While with multiple parameters

#5 Post by kangtuji »

c4c1n6kr3m1 wrote:ente ngapain bro, tinggal download aja susah susah.
replace (-)line with (+)line
for every job except novice you can use this

Code: Select all

eval $::char->{jobID} > 0
for swordman = 1, Merchant = 5 ( look inside src\globals.pm ), you can use this way

Code: Select all

eval $::char->{jobID} =~ /^1|5$/
i guess...
Bukan tinggal donglot bang, tapi ane gagal paham ... belom nyampe otak ane.
When I tries download the whole Script.pm (only Script.pm), it gives me error, so I revert back to the old version

I guess that eval could work...
A lil question, what does "^" and "$" on that regex means, thanks

Image

Post Reply