Bard Twist Mac

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

Moderator: MacroQuest Developers

Losingteam
a lesser mummy
a lesser mummy
Posts: 75
Joined: Wed May 21, 2003 8:52 pm
Location: Chicago,Illinois

Bard Twist Mac

Post by Losingteam » Sun Aug 31, 2003 5:08 pm

Bellow is the code I found somewhere on here that was done by BrainDozer. I tried using this macro as /macro Twist2.mac 53434 5237237. The spew of problems I got is as follows:

Ending macro. Calculate encountered a '
Twist2.mac@67 (initVars): /for l1 0 to $int($calc($strlen($p$l0)-1)) | l2 hold
Twist2.mac@32 (Main): /call initVars $p0 $p1
The current macro has ended.

Can only use /for during a macro.

Then I decided to try something simple and did /macro Twist2.mac 123 456. This result in the same spew of problems. So below is the code, and in bold letters is the two sections I think the problem lies within. I lack any programming comprehension, so any advice/solution would be a major thanks.

Code: Select all

| Twist2.mac  Flexible bard song twister using timers by BrainDozer. 
| 
|   Syntax:  /macro Twist2.mac [block 1] [block 2] 
| 
|     Parameter block 1 indicates non-combat songs 
|     Parameter block 2 indicates combat songs 
| 
|   Choose any combination of songs in any sequance to twist for each mode. 
| 
|     Example:  /macro Twist2.mac 256 1234234 
| 
|   This would repeat songs 2, 5 and 6 durring non-combat and songs 1, 2, 3 
|   and 4 in the above sequence while in combat.  In this instance, song 1 
|   is only twisted 1 for 7, which comes in handy for long duration songs 
|   like amplification. 
| 
|     Other Examples: /macro Twist2.mac 0 123      | Twists on attack only 
|                     /macro Twist2.mac 12345 0    | non-attack twisting only 
|                     /macro Twist2.mac 12345      | same as above 
|                     /macro Twist2.mac 9804 11    | twists 84 and 1 
| 
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
#event MissedNote "You miss a note, bringing your song to a close!" 
#define CSong  v1   | keeps track of current song number 1-max 
#define CSongf v2   | break and play song toggle (break=0 play=1) 
#define attack v4   | debug: $combat glitch work-around 
#define CSongt t1   | break and play song timer 
#define attackct t2 | debug: $combat glitch work-around check timer 
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
Sub Main 
  /stopsong 
  [b] [size=150]/call initVars $p0 $p1[/size][/b]
  :Mainloop 
     /if $attackct==0 /if $combat==TRUE /if $attack==0 /call AttackOn 
     /if $attackct==0 /if $combat==FALSE /if $attack==1 /call AttackOff 
     /if $attackct==0 /varset attackct 10     | adjustable attack check delay 
                                                           | Debug: work-around 
     /if n $v9$attack!=-1 /if $char(state)==STAND /call TwistSong $attack 
     /doevents 
  /goto :Mainloop 
/return 
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
Sub TwistSong 
   /if $CSong>$v9$p0 /varset CSong 0               | Restart twist when end of list 
   /if ($CSongf==0 && $CSongt==0) /call TS2 $p0    | Start next song in list 
   /if ($CSongf==1 && $CSongt==0) /call TS3        | Stop song and advance index 
/return 
                         | Debug: conditionals wern't playing nice with brackets 
Sub TS2 
   /cast $a($p0,$CSong) 
   /varset CSongf 1 
   /varset CSongt 40                     | adjustable play delay 
/return 

Sub TS3 
   /stopsong 
   /varset CSong $int($calc($CSong+1))   | Debug: Force integer 
   /varset CSongf 0 
   /varset CSongt 1                      | adjustable break delay 
/return 
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
Sub initVars 
  /if $p1=="" /varset p1 "0" 
  /varset v90 0                                  | v90,v91 max song index lengths 
  /varset v91 0                                  | l0 combat mode index 
  /for l0 0 to 1                                 | l1 parameter index 
      [b][size=150] /for l1 0 to $int($calc($strlen($p$l0)-1)) | l2 hold [/size][/b]
        /varset l2 $mid($l1,1,$p$l0) 
   /varset l3 $v9$l0              | Debug: array didn't like the fancy stuff 
        /if ($l2>=1 && $l2<=8) /varset a($l0,$l3) $l2  | Debug: Bracket trouble 
   /if ($l2>=1 && $l2<=8) /varset v9$l0 $int($calc($v9$l0+1)) 
     /next l1                            | Debug: it thinks it's a float-forcing 
  /next l0  
  /varset v90 $int($calc($v90-1))   | over increment fix 
  /varset v91 $int($calc($v91-1))   | 
  /varset CSong 0 
  /varset CSongt 0 
  /varset CSongf 0 
  /if $combat==TRUE /varset attack 1    | debug: inital combat values 
  /if $combat==FALSE /varset attack 0   | 
/return 
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
Sub AttackOn 
   /stopsong 
   /varset attack 1 
   /varset CSong 0               | reset sequence 
   /varset CSongt 0              | attack mode twist start delay 
   /varset CSongf 0              | force play mode 
/return 

Sub AttackOff 
   /stopsong 
   /varset attack 0 
   /varset CSong 0               | reset sequence 
   /varset CSongt 0              | attack off mode twist start delay 
   /varset CSongf 0              | force play mode 
/return 
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 
Sub Event_MissedNote 
   /varset CSongt 0              | missed note try again delay 
   /varset CSongf 0              | switch back to play mode 
/return

Narces
a lesser mummy
a lesser mummy
Posts: 37
Joined: Thu Aug 07, 2003 7:50 am

Post by Narces » Mon Sep 01, 2003 10:17 am

Have you patched your $strlen yet?

In game, type /echo $strlen("123") and if it does not echo "3" or maybe echos something like "@strlen("123")" you need to patch.

The fix for strlen can be found here. Just throw the code in, compile, and your set.

Losingteam
a lesser mummy
a lesser mummy
Posts: 75
Joined: Wed May 21, 2003 8:52 pm
Location: Chicago,Illinois

Post by Losingteam » Mon Sep 01, 2003 4:46 pm

Thanks for the lead. Going to go try that now. ~Crossing my fingers~.

Losingteam
a lesser mummy
a lesser mummy
Posts: 75
Joined: Wed May 21, 2003 8:52 pm
Location: Chicago,Illinois

Post by Losingteam » Tue Sep 02, 2003 10:17 pm

Yay!!! It works. Off to sing for hours without the worry of premature arthritis.