A=? B=? C=?

All resolved question will be found here. It is recommended that you browse / search through this section first and see if your question has been answered before

Moderators: Moderators, Documentation Writers

Message
Author
sobad123
Human
Human
Posts: 48
Joined: 17 Mar 2015, 06:48
Noob?: Yes

A=? B=? C=?

#1 Post by sobad123 »

I have a Question about the BotKiller.
The BotKiller want to solve a math problem with "How Many is A+B-C" and such things.
But the Solution I found is not working because the BotKiller use more than one variant of Check, its like:
A+B
A-B
A+B-C
A-B+C
and so on. Now my Question do I need more than one block for react on NPC or how does it work?

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: A=? B=? C=?

#2 Post by Mortimal »

Use automacro with console hook that's all.

Something like that:

Code: Select all

automacro countItForMe {
    console /(\d+)(-|\+)(\d+)(-|\+(?:\d+))/i
    call doCount
}

macro doCount {
    pause 1
    $doThis = $.lastMatch1$.lastMatch2$.lastMatch3$.lastMatch4$.lastMatch5
    $res = @eval($doThis)
    do talk num $res
}
Will trigger 2+2, 2-2, 2+2+2, 2-2-2, 2-2+2, 2+2-2
Will not trigger 2+, 2+2+, 2-, 2-2-, 2-2+, 2+2-

Just need to change that for yours corresponding full line:

Code: Select all

/(\d+)(-|\+)(\d+)(-|\+(?:\d+))/i
and this code will work fine i think:
Attachments
12431241qaaaaaa.png
12431241qaaaaaa.png (5.46 KiB) Viewed 5689 times
Last edited by Mortimal on 09 Mar 2017, 12:25, edited 2 times in total.
Please use pin function for uploading your file contents!

sobad123
Human
Human
Posts: 48
Joined: 17 Mar 2015, 06:48
Noob?: Yes

Re: A=? B=? C=?

#3 Post by sobad123 »

could you explain this line a little bit more?

Code: Select all

/(\d+)(-|\+)(\d+)(-|\+(?:\d))/i

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: A=? B=? C=?

#4 Post by Mortimal »

Code: Select all

/(\d+)(-|\+)(\d+)(-|\+(?:\d+))/i
/ /i --> delimiter - regexp inside; i - means this regexp is case-sensitive.

( ) --> delimiter - whats inside will be remembered as $.lastMatchN

\d+ --> \d - digit; + means any number of previous statement -> \d <- but not none

-|\+ --> - or +; \ here is mirror for + because + is special

?: --> used to connect \d+ statement to previous -|\+ statement (wont work without this i remember we need this but cant remember why we need this x) )

Use this for details:
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlretut.html
Please use pin function for uploading your file contents!

sobad123
Human
Human
Posts: 48
Joined: 17 Mar 2015, 06:48
Noob?: Yes

Re: A=? B=? C=?

#5 Post by sobad123 »

The seconde problem is that the Numbers are not everytime in the right position like in the picture:
Attachments
billltt.png
billltt.png (4.51 KiB) Viewed 5673 times

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: A=? B=? C=?

#6 Post by Mortimal »

Aw i get it:

Code: Select all

automacro countItForMe {
    console /Unknown\s#\d+:\s>If\s?:\s([ABC])=(\d+)\s([ABC])=(\d+)\s([ABC])=(\d+).*\nUnknown\s#\d+: How many is A\s(-|\+)\sB\s(-|\+)\sC.*/i
    call doCount
}

macro doCount {
    pause 1
    switch ($.lastMatch1) {
        case (== A){$a = $.lastMatch2}
        case (== B){$b = $.lastMatch2}
        case (== C){$c = $.lastMatch2}
    }
    switch ($.lastMatch3) {
        case (== A){$a = $.lastMatch4}
        case (== B){$b = $.lastMatch4}
        case (== C){$c = $.lastMatch4}
    }
    switch ($.lastMatch5) {
        case (== A){$a = $.lastMatch6}
        case (== B){$b = $.lastMatch6}
        case (== C){$c = $.lastMatch6}
    }
    $doThis = $a$.lastMatch7$b$.lastMatch8$c
    $res = @eval($doThis)
    do talk num $res
}
I think this will work...

..........or letters in second line also change places?
Please use pin function for uploading your file contents!

sobad123
Human
Human
Posts: 48
Joined: 17 Mar 2015, 06:48
Noob?: Yes

Re: A=? B=? C=?

#7 Post by sobad123 »

no only in first line but they can be 2 or 3 :) I will try thank you!

but it doesnt work, it doesnt trigger and have a error on switch

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: A=? B=? C=?

#8 Post by Mortimal »

use second AM

Code: Select all

automacro countItForMe2 {
    console /Unknown\s#\d+:\s>If\s?:\s([AB])=(\d+)\s([AB])=(\d+).*\nUnknown\s#\d+: How many is A\s(-|\+)\sB.*/i
    call doCount2
}

macro doCount2 {
    pause 1
    switch ($.lastMatch1) {
        case (== A){$a = $.lastMatch2}
        case (== B){$b = $.lastMatch2}
    }
    switch ($.lastMatch3) {
        case (== A){$a = $.lastMatch4}
        case (== B){$b = $.lastMatch4}
    }
    $doThis = $a$.lastMatch5$b$
    $res = @eval($doThis)
    do talk num $res
}
Please use pin function for uploading your file contents!

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: A=? B=? C=?

#9 Post by Mortimal »

What error? Better give me log console...
Please use pin function for uploading your file contents!

sobad123
Human
Human
Posts: 48
Joined: 17 Mar 2015, 06:48
Noob?: Yes

Re: A=? B=? C=?

#10 Post by sobad123 »

this one
Attachments
abcdefghaaaa.png
abcdefghaaaa.png (8.03 KiB) Viewed 5649 times

Locked