Advertisement
KeplerBR

[Macro Plugin] "__init__" and var in automacro

Sep 6th, 2014
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.84 KB | None | 0 0
  1. Index: macro.pl
  2. ===================================================================
  3. --- macro.pl    (revision 8901)
  4. +++ macro.pl    (working copy)
  5. @@ -103,6 +103,16 @@
  6.     my $file = shift;
  7.     if (parseMacroFile($file, 0)) {
  8.         Plugins::callHook ('macro/parseAndHook');
  9. +       if ($macro{'__init__'}) {
  10. +           message "[macro] calling __init__\n";
  11. +           $queue = new Macro::Script('__init__');
  12. +           if (defined $queue) {
  13. +               $queue->interruptible(0);
  14. +               callMacro
  15. +           } else {
  16. +               error "unable to create macro queue.\n"
  17. +           }
  18. +       }
  19.         &hookOnDemand; return 1
  20.     }
  21.     error "error loading $file.\n";
  22. Index: Macro/Automacro.pm
  23. ===================================================================
  24. --- Macro/Automacro.pm  (revision 8901)
  25. +++ Macro/Automacro.pm  (working copy)
  26. @@ -20,6 +20,7 @@
  27.  use Macro::Utilities qw(between cmpr match getArgs refreshGlobal
  28.     getPlayerID getSoldOut getInventoryAmount getCartAmount getShopAmount
  29.     getStorageAmount callMacro sameParty);
  30. +use Macro::Parser qw(subvars);
  31.  
  32.  our ($rev) = q$Revision: 6760 $ =~ /(\d+)/;
  33.  
  34. @@ -277,18 +278,6 @@
  35.         return 0
  36.     }
  37.     my ($item, $cond, $amount) = getArgs($check);
  38. -   if ($item =~ /^\$/) {
  39. -       my ($var) = $item =~ /^\$([a-zA-Z][a-zA-Z\d]*)\s*/;
  40. -       return 0 unless defined $var;
  41. -       if (exists $varStack{$var}) {$item = $varStack{$var}}
  42. -       else {return 0}
  43. -   }
  44. -   if ($amount =~ /^\$/) {
  45. -       my ($var1) = $amount =~ /^\$([a-zA-Z][a-zA-Z\d]*)\s*/;
  46. -       return 0 unless defined $var1;
  47. -       if (exists $varStack{$var1}) {$amount = $varStack{$var1}}
  48. -       else {return 0}
  49. -   }
  50.     my $what;
  51.     if ($where eq 'inv')  {$what = getInventoryAmount($item)}
  52.     if ($where eq 'cart') {$what = getCartAmount($item)}
  53. @@ -765,29 +754,30 @@
  54.         next CHKAM if (defined $automacro{$am}->{whenGround} && !checkGround($automacro{$am}->{whenGround}));
  55.         next CHKAM if (defined $automacro{$am}->{notMonster} && !checkMonster($automacro{$am}->{notMonster}, 1));
  56.  
  57. -       foreach my $i (@{$automacro{$am}->{monster}})    {next CHKAM unless checkMonster($i)}
  58. -       foreach my $i (@{$automacro{$am}->{aggressives}}){next CHKAM unless checkAggressives($i)}
  59. -       foreach my $i (@{$automacro{$am}->{location}})   {next CHKAM unless checkLoc($i)}
  60. -       foreach my $i (@{$automacro{$am}->{localtime}})  {next CHKAM unless checkLocalTime($i, "")}
  61. +      
  62. +       foreach my $i (@{$automacro{$am}->{monster}})    {next CHKAM unless checkMonster(subvars($i))}
  63. +       foreach my $i (@{$automacro{$am}->{aggressives}}){next CHKAM unless checkAggressives(subvars($i))}
  64. +       foreach my $i (@{$automacro{$am}->{location}})   {next CHKAM unless checkLoc(subvars($i))}
  65. +       foreach my $i (@{$automacro{$am}->{localtime}})  {next CHKAM unless checkLocalTime(subvars($i), "")}
  66.         foreach my $i (@{$automacro{$am}->{var}})        {next CHKAM unless checkVar($i, "")}
  67.         foreach my $i (@{$automacro{$am}->{varvar}})     {next CHKAM unless checkVar($i, "varvar")}
  68. -       foreach my $i (@{$automacro{$am}->{base}})       {next CHKAM unless checkLevel($i, "lv")}
  69. -       foreach my $i (@{$automacro{$am}->{job}})        {next CHKAM unless checkLevel($i, "lv_job")}
  70. -       foreach my $i (@{$automacro{$am}->{hp}})         {next CHKAM unless checkPercent($i, "hp")}
  71. -       foreach my $i (@{$automacro{$am}->{sp}})         {next CHKAM unless checkPercent($i, "sp")}
  72. -       foreach my $i (@{$automacro{$am}->{spirit}})     {next CHKAM unless checkCond($char->{spirits} || 0, $i)}
  73. -       foreach my $i (@{$automacro{$am}->{weight}})     {next CHKAM unless checkPercent($i, "weight")}
  74. -       foreach my $i (@{$automacro{$am}->{cartweight}}) {next CHKAM unless checkPercent($i, "cweight")}
  75. -       foreach my $i (@{$automacro{$am}->{soldout}})    {next CHKAM unless checkCond(getSoldOut(), $i)}
  76. -       foreach my $i (@{$automacro{$am}->{zeny}})       {next CHKAM unless checkCond($char->{zeny}, $i)}
  77. -       foreach my $i (@{$automacro{$am}->{cash}})       {next CHKAM unless checkCond($cashShop{points}->{cash}?$cashShop{points}->{cash}:0, $i)}
  78. -       foreach my $i (@{$automacro{$am}->{player}})     {next CHKAM unless checkPerson($i)}
  79. -       foreach my $i (@{$automacro{$am}->{equipped}})   {next CHKAM unless checkEquip($i)}
  80. -       foreach my $i (@{$automacro{$am}->{status}})     {next CHKAM unless checkStatus($i)}
  81. -       foreach my $i (@{$automacro{$am}->{inventory}})  {next CHKAM unless checkItem("inv", $i)}
  82. -       foreach my $i (@{$automacro{$am}->{storage}})    {next CHKAM unless checkItem("stor", $i)}
  83. -       foreach my $i (@{$automacro{$am}->{shop}})       {next CHKAM unless checkItem("shop", $i)}
  84. -       foreach my $i (@{$automacro{$am}->{cart}})       {next CHKAM unless checkItem("cart", $i)}
  85. +       foreach my $i (@{$automacro{$am}->{base}})       {next CHKAM unless checkLevel(subvars($i), "lv")}
  86. +       foreach my $i (@{$automacro{$am}->{job}})        {next CHKAM unless checkLevel(subvars($i), "lv_job")}
  87. +       foreach my $i (@{$automacro{$am}->{hp}})         {next CHKAM unless checkPercent(subvars($i), "hp")}
  88. +       foreach my $i (@{$automacro{$am}->{sp}})         {next CHKAM unless checkPercent(subvars($i), "sp")}
  89. +       foreach my $i (@{$automacro{$am}->{spirit}})     {next CHKAM unless checkCond($char->{spirits} || 0, subvars($i))}
  90. +       foreach my $i (@{$automacro{$am}->{weight}})     {next CHKAM unless checkPercent(subvars($i), "weight")}
  91. +       foreach my $i (@{$automacro{$am}->{cartweight}}) {next CHKAM unless checkPercent(subvars($i), "cweight")}
  92. +       foreach my $i (@{$automacro{$am}->{soldout}})    {next CHKAM unless checkCond(getSoldOut(), subvars($i))}
  93. +       foreach my $i (@{$automacro{$am}->{zeny}})       {next CHKAM unless checkCond($char->{zeny}, subvars($i))}
  94. +       foreach my $i (@{$automacro{$am}->{cash}})       {next CHKAM unless checkCond($cashShop{points}->{cash}?$cashShop{points}->{cash}:0, subvars($i))}
  95. +       foreach my $i (@{$automacro{$am}->{player}})     {next CHKAM unless checkPerson(subvars($i))}
  96. +       foreach my $i (@{$automacro{$am}->{equipped}})   {next CHKAM unless checkEquip(subvars($i))}
  97. +       foreach my $i (@{$automacro{$am}->{status}})     {next CHKAM unless checkStatus(subvars($i))}
  98. +       foreach my $i (@{$automacro{$am}->{inventory}})  {next CHKAM unless checkItem("inv", subvars($i))}
  99. +       foreach my $i (@{$automacro{$am}->{storage}})    {next CHKAM unless checkItem("stor", subvars($i))}
  100. +       foreach my $i (@{$automacro{$am}->{shop}})       {next CHKAM unless checkItem("shop", subvars($i))}
  101. +       foreach my $i (@{$automacro{$am}->{cart}})       {next CHKAM unless checkItem("cart", subvars($i))}
  102.  
  103.         message "[macro] automacro $am triggered.\n", "macro";
  104.  
  105. Index: Macro/Parser.pm
  106. ===================================================================
  107. --- Macro/Parser.pm (revision 8901)
  108. +++ Macro/Parser.pm (working copy)
  109. @@ -6,8 +6,8 @@
  110.  
  111.  require Exporter;
  112.  our @ISA = qw(Exporter);
  113. -our @EXPORT = qw(parseMacroFile parseCmd isNewCommandBlock);
  114. -our @EKSPORT_OK = qw(parseCmd isNewCommandBlock);
  115. +our @EXPORT = qw(subvars parseMacroFile parseCmd isNewCommandBlock);
  116. +our @EKSPORT_OK = qw(subvars parseCmd isNewCommandBlock);
  117.  
  118.  use Globals;
  119.  use Utils qw/existsInList/;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement