Need help for multiple callings...

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Wraeth
orc pawn
orc pawn
Posts: 16
Joined: Sun Dec 21, 2003 10:18 am

Need help for multiple callings...

Post by Wraeth » Mon Apr 26, 2004 6:02 pm

Okay, this is the first macro I've done, so I know it's probably kind of ugly. It switches out clickies with what I'm wearing, casts the clickie, then switches them back out again and cleans everything up. I've got it working for one item at a time, but I'm wondering if anyone can help me make it so I can call it for multiple items (IE /macro switch2 robe shield sow)

Code: Select all

Sub Main
  /declare Clickie local
  /declare Pack local
  /declare PackSlot local
  /declare ClickSlot local
  /declare CastTime local
  /declare Switch array
  /declare InputParam local
  /declare ArrayCount local  
  /declare IniInput local
  
  /varset InputParam @Param0
  /varset ArrayCount 1

  :MakeArray
    /varset Switch(@ArrayCount) ${String["@InputParam"].Arg[@ArrayCount,;]}
    /if (!${Ini[clickies.ini,Items,${String["@Switch(@ArrayCount)"]}].Length}) {
      /echo ERROR: @Switch(@ArrayCount) is invalid.
      /goto :SwitchDone
    }
    /varadd ArrayCount 1
    /if (!${String["@InputParam"].Arg[@ArrayCount,;].Length}) {
      /varset ArrayCount 1
      /goto :SwitchOut
    }
  /goto :MakeArray

  :SwitchOut

  /if (${String[@Switch(@ArrayCount)].Equal["UNDEFINED-ARRAY-ELEMENT"]}) /goto :SwitchDone
  /varset IniInput "${Ini[clickies.ini,Items,${String["@Switch(@ArrayCount)"]}]}"
  /varset Clickie "${String["@IniInput"].Arg[1,;]}"
  /varset Pack "${String["@IniInput"].Arg[2,;]}"
  /varset PackSlot "${String["@IniInput"].Arg[3,;]}"
  /varset ClickSlot "${String["@IniInput"].Arg[4,;]}"
  /varset CastTime "${String["@IniInput"].Arg[5,;]}"

  :SwitchNClick
    /echo Now switching ${Me.Inventory["@ClickSlot"].Name} with @Clickie
    /if (!${Window[InventoryWindow].Open}) {
       /keypress inventory
    }
    /if (!${Window[${InvSlot[@Pack].Name}].Open}) {
       /itemnotify pack2 rightmouseup
    }
    /itemnotify in ${String[@Pack]} ${String[@PackSlot]} leftmouseup
    /delay 1
    /itemnotify ${String[@ClickSlot]} leftmouseup
    /delay 1
    /itemnotify ${String[@ClickSlot]} rightmouseup
    /delay ${Math.Calc[${Float["@CastTime"]}+1]}s
    /itemnotify ${String[@ClickSlot]} leftmouseup
    /delay 1
    /itemnotify in ${String[@Pack]} ${String[@PackSlot]} leftmouseup
    /delay 1

  :SwitchDone
    /zapvars
    /cleanup
/return
Here's an example of the INI if you really need:

Code: Select all

[Items]
Robe=Koadic's Robe of Heightened Focus;pack2;1;chest;6.5
Shield=Shield of Auras;pack2;2;offhand;7
Resist=String of Beaded Slime;pack2;6;leftwrist;1
Sow=Yttrium Studded Leather Boots;pack2;3;feet;12
Xuzl=Amulet of Xuzl;pack2;4;neck;10
Thanks in advance

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Mon Apr 26, 2004 8:32 pm

Wow, this is striking fimiliar to one that I've written myself. Here is the snippet from my code where I allow multiply keys to be entered.

Code: Select all

  :FillArray
|@ArrayCount is a simple int type
|@InputParam was set to equal "@Param0" somewhere at the begining of my code.
    /varset Switches(@ArrayCount) ${String["@InputParam"].Arg[@ArrayCount,;]}
    /if (!${Ini[druid.ini,ItemSwitch,${String["@Switches(@ArrayCount)"]}].Length}) {
      /echo NOT FOUND: @Switches(@ArrayCount)
      /goto :EndSwitch
    }
    /varadd ArrayCount 1
    /if (!${String["@InputParam"].Arg[@ArrayCount,;].Length}) {
      /call HandlePacks 1
      /varset ArrayCount 1
      /goto :StartSwitch
    }
  /goto :FillArray
Basically let me do this: /macro switch Arms;Legs;Prim;Sec;Ect.
I'm rewritting this part of the code to get rid of the array and simply run the whole script with one segment of the input parameter and then loop, get the next segment, run again. Hope it gives you some ideas.

Wraeth
orc pawn
orc pawn
Posts: 16
Joined: Sun Dec 21, 2003 10:18 am

Post by Wraeth » Mon Apr 26, 2004 8:36 pm

Yours is probably the one I used to figure out how the code went. ^.^ I forgot who wrote it and couldn't find it again, so if it is you, here's the credits!

Thanks :)

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Mon Apr 26, 2004 8:59 pm

:) No credit needed. I never got around to coding in a sub to rightclick the item and then put it back. I also love the pack and slot defines in the ini file. Makes it a little less flexable but a whole lot cleaner. Mine had to open all the packs in inventory.

Havin' a pain trying to get switch.mac converted over to the new ${} system. Prolly just gonna spend the night rewriting the whole damn thing.

Wraeth
orc pawn
orc pawn
Posts: 16
Joined: Sun Dec 21, 2003 10:18 am

Post by Wraeth » Mon Apr 26, 2004 9:30 pm

Well, since I bagged every piece of clicky equippment I have, I just had to come up with some way to click it all without clickclickclickclick... And since opening every bag while on a raid would lag me to hell and back, I had to limit what it does. Yours had part of the functionality I wanted, I just had to add in the click and reswitch.

Now, my code is still pretty much set up the way yours is, but I CTD if I try to call multiple items. So, still trying to figure that out.