Question

I'm working on an imacros script for an online rpg and I ended up writing this:

var i;
for(var i=1;i<=9999;i++) {
    iimDisplay(i);
var macro;
var retcode, macro2;
macro = "CODE:";
macro += "SET !ERRORIGNORE YES\n";
macro += "URL GOTO=http://coolsite.com/bttle.php?page=map\n";
macro += "TAG POS=1 TYPE=INPUT:IMAGE FORM=NAME:Cave ATTR=SRC:http://coolsite.com/images/maps/cave.gif\n";
macro += "TAG POS=1 TYPE=STRONG ATTR=TXT:Magby EXTRACT=TXT\n";

retcode = iimPlay(macro);

if (iimGetLastExtract(1)=='Marty'){
G_Extract = "CODE:";
G_Extract=G_Extract+"TAG POS=1 TYPE=SELECT ATTR=ID:item CONTENT=%Kill<SP>him\n";
G_Extract+=G_Extract+"TAG POS=1 TYPE=BUTTON ATTR=ID:use_item\n";
iimPlay(G_Extract);
}
else if (iimGetLastExtract(1)!=="Marty")
{
macro2 = "CODE:";
macro2 += "TAG POS=1 TYPE=BUTTON ATTR=ID:run\n";
macro2 += "SET !EXTRACT NULL\n";
macro2 +="Wait seconds=2.5\n";
iimPlay(macro2);
}


}

What it does is that if enemy, "Marty" is found, then we need to kill him, otherwise if enemy found is not Marty, then we need to run. Now, the first part does its job and it always clicks on the map to search for enemies, and after that it searches for the text "Marty" on the screen. But, even if it finds it and selects it, it still thinks there is no Marty on the page, so proceeds to run, never battle. PLEASE HELP mE GUYS.

Was it helpful?

Solution 2

macro += "TAG POS=1 TYPE=STRONG ATTR=TXT:Magby EXTRACT=TXT\n";

I see here says "Magby" so this iMacros code will extract text with value "Magby". Try changing this to Marty and see does it work.

var i;
for(var i=1;i<=9999;i++) {
    iimDisplay(i);
var macro;
var retcode, macro2;
macro = "CODE:";
macro += "SET !ERRORIGNORE YES\n";
macro += "URL GOTO=http://coolsite.com/bttle.php?page=map\n";
macro += "TAG POS=1 TYPE=INPUT:IMAGE FORM=NAME:Cave ATTR=SRC:http://coolsite.com/images/maps/cave.gif\n";
macro += "TAG POS=1 TYPE=STRONG ATTR=TXT:Magby EXTRACT=TXT\n";

retcode = iimPlay(macro);

var extracted=iimGetLastExtract();

extracted=extracted.trim();

if (iimGetLastExtract(1)=='Marty'){
G_Extract = "CODE:";
G_Extract=G_Extract+"TAG POS=1 TYPE=SELECT ATTR=ID:item CONTENT=%Kill<SP>him\n";
G_Extract+=G_Extract+"TAG POS=1 TYPE=BUTTON ATTR=ID:use_item\n";
iimPlay(G_Extract);
}
else if (iimGetLastExtract(1)!=="Marty")
{
macro2 = "CODE:";
macro2 += "TAG POS=1 TYPE=BUTTON ATTR=ID:run\n";
macro2 += "SET !EXTRACT NULL\n";
macro2 +="Wait seconds=2.5\n";
iimPlay(macro2);
}


}

I do not prefer to put extract and if clause together. So changed it a little bit. Also I trimmed the string to remove any blank space from the side. If this doesn't work, use alert to check the values and toLowerCase() method could help you.

OTHER TIPS

probably it does not finds it. try to debug found values using:

alert(iimGetLastExtract(1));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top