Ts.mac and Cheese.mac combined... problems

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

pab05
a lesser mummy
a lesser mummy
Posts: 42
Joined: Thu Aug 14, 2003 12:24 am

Ts.mac and Cheese.mac combined... problems

Post by pab05 » Thu Aug 14, 2003 10:36 pm

I tried to combine Ts.mac and Cheese.mac
Im not the best coder so the mistake i made may be simple.

This is the code im using mostly from the Ts.mac thanks so much : ) and Cheese.mac nothing really of my own but i tried to combine the buying/selling of cheese.mac to ts.mac to get it to work.... but yeah i got some problems. When it gets to the buying and selling it just does not seem to cooperate. The buying and selling however works on my cheese.mac the combines just don't work. What needs to be changed in this code.

Code: Select all

#turbo 
#define CombStr v1 
#define CombInt v2 
#define TotalComp v3 
#define dly v4 
#define abt v5 
#define cbe v6 
#define SkillFailCounter v50 
#define SkillSuccessCounter v51 
#define SuccessRate v53 
#define TotalAttempts v54 
#define SkillUpCounter v55 
#define SkillUpRate v56 

#event SkillUp "You have become better at" 
#event SkillFailure "You lacked the skills" 
#event SkillSuccess "You have fashioned the items together to create something new" 
#event FullInventory "There was no place to put that" 
#event CombineError "You cannot combine these items in this container type!" 
#chat tell 

Sub Main 
   |/cleanup 
   /varset SkillFailCounter 0 
   /varset SkillSuccessCounter 0 
   /varset SuccessRate 0 
   /varset TotalAttempts 0 
   /varset SkillUpRate 0 
   /varset SkillUpCounter 0 
   | SET THE DELAY BETWEEN MOUSE CLICKS HERE 
   /varset dly 10 
   | ABORT ON RECIEVING A TELL, SET TO "TRUE" or "FALSE" 
   /varset abt "FALSE" 
   /call ClearCursor $p0 
   /if "$p2"=="" { 
      /echo Syntax: /macro ts <Keep|Destroy> <CombinerName> <Component> [Component]... 
      /endmacro 
   } 
   /call CombFind "$p1" 
   /if $CombInt<=7 /call OpenInv 
   /if $CombInt==8 { 
      /call OpenEnv 
      /delay $dly 
   } 
   /if $CombInt>=98 /if $CombInt<=99 { 
      /if n $CombInt==99 /echo Cannot find container << $p1 >> 
      /if n $CombInt==98 /echo Too far away from << $p1 >> 
      /endmacro 
   } 
   /call HandlePacks open 
   /varset TotalComp 0 
   /call ClearCursor $p0 
   :CountComponents 
      /varset a(1,$TotalComp) "$p$int($calc($TotalComp+2))" 
      /varadd TotalComp 1 
      /if n $int($TotalComp)>10 { 
         /echo Syntax: /macro ts <Keep|Destroy> <CombinerName> <Component> [Component]... 
         /echo You can only add up to a total of 10 components. 
         /endmacro 
      } 
      /echo Component $int($TotalComp): $p$int($calc($TotalComp+1)) 
      /if "$p$int($calc($TotalComp+2))"~~"$" { 
         /goto :Begin 
      } else /if "$p$int($calc($TotalComp+2))"=="" { 
         /goto :Begin 
      } else { 
         /goto :CountComponents 
      } 
   :Begin 
        /doevents 
      /for l0 0 to $int($calc($TotalComp-1)) 
         /call AddComp "$a(1,$l0)" $l0 
      /next l0 

   :Combine 
        /doevents 
      /call DoCombine 

   :ClearCursor 
      /doevents 
      /call ClearCursor $p0 
   /goto :Begin 
/return 

Sub CleanPack 
   /press ctrl 
   /sendkey down shift 
   /if "$CombStr"=="enviro" { 
      /varset l0 10 
   } else { 
      /varcalc l0 $pack($CombInt,slots)-1 
   } 

   /for l1 0 to $l0 
      /click left $CombStr $l1 
      /delay $dly 
      /click left auto 
      /click left auto 
      /delay $dly 
   /next l1 
   /sendkey up shift 
   /press shift 
/return 

Sub HandlePacks 
   /varset l0 0 
   /if "$p0"=="open" /goto :Open 
   /if "$p0"=="close" /goto :Close 
   /if "$p0"=="" /goto :Syntax 
   :Open 
      /for l0 0 to 7 
         /if "$pack($int($l0))"=="TRUE" /if "$pack($int($l0),open)"=="FALSE" /click right inv $int($l0) 
         /delay $dly 
      /next l0 
      /goto :End 
   :Close 
      /for l0 0 to 7 
         /if "$pack($int($l0))"=="TRUE" /if "$pack($int($l0),open)"=="TRUE" /click right inv $int($l0) 
         /delay $dly 
      /next l0 
      /goto :End 
   :Syntax 
      /echo Syntax: /call HandlePacks <open|close> 
      /endmacro 
   :End 
/return 

Sub OpenInv 
   /varset CombStr "pack $CombInt" 
   /if "$pack($int($l0),open)"=="FALSE" /click right inv $int($l0) 
   /delay $dly 
   /if $pack($CombInt,empty)==FALSE /call CleanPack 
/return 

Sub OpenEnv 
   /varset CombInt e 
   /varset CombStr enviro 
   /face item 
   /delay $dly 
   |/click left item 
   |/delay $dly 
| Code currently not functioning. 
|   :WaitOpen 
|      /if $pack($CombInt,open)==FALSE /goto :WaitOpen 
|   /delay $dly 
|   /if $pack($CombInt,empty)==FALSE /call CleanPack 
/return 

sub ClearCursor 
   :Loop 
      /delay $dly 
      /if $cursor()!=NULL { 
         /if "$p0"=="DESTROY" { 
            /varset l0 0 
            :SubLoop 
               /if "$a(1,$l0)"~~"#" { 
                  /varset l1 "$right($calc($strlen("$a(1,$l0)")-1),"$a(1,$l0)")" 
                  /varset l2 0 
               } else { 
                  /varset l1 "$a(1,$l0)" 
                  /varset l2 1 
               } 

               /if n $l2==0 /if "$cursor(name)"~~"$l1" { 
                     /click left auto 
                     /click left auto 
                     /delay $dly 
               } else /if n $l2==1 /if "$cursor(name)"=="$l1" { 
                     /click left auto 
                     /click left auto 
                     /delay $dly 
               } 
               /if "$cursor()"!="NULL" { 
                  /if n $l0<$TotalComp { 
                     /varadd l0 1 
                     /goto :SubLoop 
                  } else { 
                     /click left destroy 
                     /delay $dly 
                  } 
               } 
         } else { 
            /click left auto 
            /click left auto 
            /delay $dly 
         } 
      } 
      /if $cursor()!=NULL /goto :Loop 
/return 

sub DoCombine 
   :Loop 
      | CLICK LEFT COMBINE MISSES THE COMBINE BUTTON WITH MY UI, TEMPORARY FIX BY SETTING IT TO DONE. 
      | /click left $CombStr done 
      /click left $CombStr combine 
      /doevents 
      /delay $dly 
      /if $pack($CombInt,empty)==FALSE /goto :Loop 
/return 

sub AddComp 
   /press shift 
   /sendkey down ctrl 
   /if "$p0"~~# { 
      /finditem similar "$right($calc($strlen("$p0")-1),"$p0")" 
   } else { 
      /finditem "$p0" 
   } 
   /if $find()==FALSE /goto :NoComp 
   /delay $dly 
   /click left $CombStr $p1 
   /goto :End 
   :NoComp 
      /echo Could not find << $p0 >> 
      /call SellBuy 
   :End 
      /sendkey up ctrl 
      /press ctrl 
/return 

Sub CombFind 
   /varset CombInt 99 
   /if "$p0"~~"#" { 
      /varset l1 "$right($calc($strlen("$p0")-1),"$p0")" 
      /varset l2 0 
   } else { 
      /varset l1 "$p0" 
      /varset l2 1 
   } 
   /for l3 0 to 7 
      /if n $l2==0 /if "$pack($l3,name)"~~"$l1" /varset CombInt $l3 
      /if n $l2==1 /if "$pack($l3,name)"=="$l1" /varset CombInt $l3 
   /next l3 
   /if n $CombInt==99 { 
      /itemtarget $p0 
      /if n $ground(id)==0 /varset CombInt 99 
      /if n $distance(item)>20 /varset CombInt 98 
      /if n $ground(id)>0 /if n $distance(item)<=20 /varset CombInt 8 
   } 
/return $CombInt 

Sub EndCombines 
   /call CleanPack 
   |/cleanup 
   /echo Successes: $int($SkillSuccessCounter), Failures: $int($SkillFailCounter) 
   /varcalc TotalAttempts $SkillFailCounter + $SkillSuccessCounter 
   /varcalc SuccessRate $SkillSuccessCounter / $TotalAttempts * 100 
   /varcalc SkillUpRate $SkillUpCounter / $TotalAttempts * 100 
   /echo Successes Rate: $int($SuccessRate) % out of $int($TotalAttempts) attempts 
   /if n $SkillUpCounter>0 /echo Skill Ups: $int($SkillUpCounter) , Skill Rate: $int($SkillUpRate) % out of 

$int($TotalAttempts) attempts 
   /echo "/camp"
   /endmacro 
/return 

Sub Event_Chat 
   /if "$abt"=="TRUE" { 
      /echo Got a tell, stopping. 
      /call EndCombines 
   } 
/return 

Sub Event_CombineError 
   /echo You cannot combine these items in this container type! 
   /call EndCombines 
/return 

Sub Event_FullInventory 
   /echo Your inventory is full, ending macro. 
   /call SellBuy 
/return 

Sub Event_SkillFailure 
    /varadd SkillFailCounter 1 
/return 

Sub Event_SkillSuccess 
    /varadd SkillSuccessCounter 1 
/return 

Sub SellBuy 

   | Open merchant 
   /sendkey up ctrl
   /sendkey up shift
   /click left auto 
   /target "merchantname" 
   /face 
   /press u
   /varset v55 0 
   /doevents flush 
   :sellwait 
   /doevents 
   /if n $v55!=1 /goto :sellwait 

   /sendkey down shift 

   | Sell our cheese 
   :SellCheese 
      /finditem "Mature Cheese" 
      /if $find()==FALSE /goto :DoneSelling 
      /click left merchant buy
   /goto :SellCheese 

   :DoneSelling 
   /varset v51 0 
   /finditem "Rennet" 
   /if $find()==TRUE /varset v51 1 
   /finditem "Bottle of Milk" 
   /if $find()==TRUE /if n $v80!=$find(pack) /goto :SkipMilk 

   | Buy Bottles of Milk
   /click left merchant 9 
   /call BuyItem 
   /call BuyItem 
   /call BuyItem  
   /call BuyItem 

   | If we had Rennet left, buy extra milk 
   /if n $v51==0 /goto :SkipMilk 
   /call BuyItem 
   :SkipMilk 

   | Buy Rennets 
   /click left merchant 10 
   /call BuyItem 
   /call BuyItem

   /sendkey up shift 
   /cleanup 
   :cleanuploop1 
    /if "$target()"=="TRUE" /goto :cleanuploop1 

/return 

Sub BuyItem 
   /sendkey down shift
   /varcalc v98 $char(gold)*100+$char(silver)*10+$char(copper) 
   /click left merchant buy 
   :WaitBuy 
      /varcalc v97 $char(gold)*100+$char(silver)*10+$char(copper)
/return

Sub Event_SkillUp 
   /varadd SkillUpCounter 1 
   /echo $int($SkillUpCounter) skill ups in $int($calc($SkillFailCounter+$SkillSuccessCounter)) Attempts! 
/return 
edited out merchant name
Last edited by pab05 on Fri Aug 15, 2003 9:45 am, edited 1 time in total.

Shin Noir
a ghoul
a ghoul
Posts: 90
Joined: Tue Aug 05, 2003 8:18 pm

Re: Ts.mac and Cheese.mac combined... problems

Post by Shin Noir » Fri Aug 15, 2003 7:08 am

pab05 wrote:I tried to combine Ts.mac and Cheese.mac
Im not the best coder so the mistake i made may be simple.

This is the code im using mostly from the Ts.mac thanks so much : ) and Cheese.mac nothing really of my own but i tried to combine the buying/selling of cheese.mac to ts.mac to get it to work.... but yeah i got some problems. When it gets to the buying and selling it just does not seem to cooperate. The buying and selling however works on my cheese.mac the combines just don't work. What needs to be changed in this code.
Hrm lots of code to sort through. What's your problem exactly? Any errors reported? Does it tell you a line the error is in? Does it click blank areas of the screen? I'll run it if you don't respond by the time I get home but knowing what exactly the error is can really help than just saying "It doesn't seem to cooperate".

pab05
a lesser mummy
a lesser mummy
Posts: 42
Joined: Thu Aug 14, 2003 12:24 am

The problem

Post by pab05 » Fri Aug 15, 2003 9:44 am

The problem comes whenever sellbuy is called. It just does not work if i comment out the sell wait it will go to the actual selling and the mouse will just lock up on the buy button without selecting any cheese, or anything all the bags are open, and and when i end the macro and run the / click left merchant buy commnad it works and so does finditem cheese. I just can't figure ot what is causing this.

this is the exat code that is malfunctioning

Code: Select all

Sub SellBuy 

   | Open merchant 
   /sendkey up ctrl 
   /sendkey up shift 
   /click left auto 
   /target "merchantname" 
   /face 
   /press u 
   /varset v55 0 
   /doevents flush 
   :sellwait 
   /doevents 
   /if n $v55!=1 /goto :sellwait 

   /sendkey down shift 

   | Sell our cheese 
   :SellCheese 
      /finditem "Mature Cheese" 
      /if $find()==FALSE /goto :DoneSelling 
      /click left merchant buy 
   /goto :SellCheese 

   :DoneSelling 
   /varset v51 0 
   /finditem "Rennet" 
   /if $find()==TRUE /varset v51 1 
   /finditem "Bottle of Milk" 
   /if $find()==TRUE /if n $v80!=$find(pack) /goto :SkipMilk 

   | Buy Bottles of Milk 
   /click left merchant 9 
   /call BuyItem 
   /call BuyItem 
   /call BuyItem  
   /call BuyItem 

   | If we had Rennet left, buy extra milk 
   /if n $v51==0 /goto :SkipMilk 
   /call BuyItem 
   :SkipMilk 

   | Buy Rennets 
   /click left merchant 10 
   /call BuyItem 
   /call BuyItem 

   /sendkey up shift 
   /cleanup 
   :cleanuploop1 
    /if "$target()"=="TRUE" /goto :cleanuploop1 

/return 

pab05
a lesser mummy
a lesser mummy
Posts: 42
Joined: Thu Aug 14, 2003 12:24 am

Post by pab05 » Fri Aug 15, 2003 9:50 am

The above code is being called here if that helps.

Code: Select all

sub AddComp 
   /press shift 
   /sendkey down ctrl 
   /if "$p0"~~# { 
      /finditem similar "$right($calc($strlen("$p0")-1),"$p0")" 
   } else { 
      /finditem "$p0" 
   } 
   /if $find()==FALSE /goto :NoComp 
   /delay $dly 
   /click left $CombStr $p1 
   /goto :End 
   :NoComp 
      /echo Could not find << $p0 >> 
      /call SellBuy 
   :End 
      /sendkey up ctrl 
      /press ctrl 
/return 

pab05
a lesser mummy
a lesser mummy
Posts: 42
Joined: Thu Aug 14, 2003 12:24 am

Thanks i got it

Post by pab05 » Fri Aug 15, 2003 12:48 pm

I have just figured out the power of /doevents : ) thanks thou

it seems to work now