Conditional statement fails

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

Moderator: Moderators

Message
Author
gooey
Noob
Noob
Posts: 10
Joined: 06 Jul 2018, 15:27
Noob?: Yes

Conditional statement fails

#1 Post by gooey »

I would like to seek help. My conditional statement is not working. I do not understand why.
Code fragment

Code: Select all

		log $.lvl
		log @eval($::char->{jobID})
		if ($.lvl >= "85") {
			log i1
			switch ("@eval($::char->{jobID})") {
				log i2
				case (=~ /1|7|4008|4060|14|4015|4073|5|10|18|4011|4019|4064|4078|2|9|4010|4061|17|4018|4079|4046|24|4215/i) {
					log i3
					$aspdPots = "Berserk Potion"
				}
			}
		} elsif ($.lvl >= "40" && $.lvl < "85") {
			log i4
			$aspdPots = "Awakening Potion"
		} else {
			log i5
			$aspdPots = "Concentration Potion"
		}
		log $aspdPots eee
		do conf useSelf_item_0 $aspdPots
		do conf useSelf_item_0_whenStatusInactive $aspdPots
This is the output

Code: Select all

[macro log] 75
[macro log] 4019
[macro log]  eee
Config 'useSelf_item_0' is Awakening Potion
Config 'useSelf_item_0_whenStatusInactive' is Awakening Potion
To me, the lines 4 & 5 in the output seems to "query" only the useSelf_item_0, instead of "replace" it. Quite evident on line 3.
I also tried removing the "" from the @eval & the numbers but it does not help.
Can you help me spot what is the problem?

Thanks.

User avatar
fadreus
The Kore Devil
The Kore Devil
Posts: 708
Joined: 17 Nov 2017, 23:32
Noob?: No
Location: Genting Highland, Malaysia
Contact:

Re: Conditional statement fails

#2 Post by fadreus »

So you trying to check useSelf_item speed potion based on level, and change accordingly?
I could think a simple solution if this is what you wanted. :)

Have you tried with eventMacro.pl?
Automacro ConfigKey is what you need, I think. :?

Macro.pl is no longer being updated, though it still working.

iRO Supporter.
Read before you ask is the wisest thing human can do.
Unless you're a cat.
Image

forbbs
Human
Human
Posts: 30
Joined: 26 Jul 2011, 21:03
Noob?: Yes

Re: Conditional statement fails

#3 Post by forbbs »

try to use some temporary var.
like that

Code: Select all

log $.lvl
templv=$.lvl
if(templv <= 85) {
}

gooey
Noob
Noob
Posts: 10
Joined: 06 Jul 2018, 15:27
Noob?: Yes

Re: Conditional statement fails

#4 Post by gooey »

I forgot I posted something here. :lol:

But anyway, I was able to figure out now what the problem is.

The condition becomes true if the jobID has 1 or 7 or anything in there. (e.g. 4614 will be true)
So I had separate entry for those "unique" values.

Checked the ConfigKey but it looks quite tedious to me. Maybe in the future. :lol:

Thanks anyway~

User avatar
SkylorD
Moderators
Moderators
Posts: 1167
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil
Contact:

Re: Conditional statement fails

#5 Post by SkylorD »

gooey wrote:I forgot I posted something here. :lol:

But anyway, I was able to figure out now what the problem is.

The condition becomes true if the jobID has 1 or 7 or anything in there. (e.g. 4614 will be true)
So I had separate entry for those "unique" values.

Checked the ConfigKey but it looks quite tedious to me. Maybe in the future. :lol:

Thanks anyway~
It's because you're using regular expression to match the pattern. You've used :

1 | 7 -> it means one or seven. They will trigger with 17 too.

2 | 9 -> will catch 4019.


Nice you've learned.

http://jkorpela.fi/perl/regexp.html

Take a look at 'alternative' symbol.
Learn rules

Post Reply