Raiding Bufflist

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

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Raiding Bufflist

Post by Slice » Tue Oct 28, 2003 6:33 pm

I'm almost done with a macro to store a bufflist for raids, allow you to make modifications to the bufflist, and spit it out to a channel or write it to the ini on command.

The problem I'm having is that it doesn't recognize anything I put into the private chat channel so none of the commands are processed. I can't even get it to fire the event_chat sub. What am I missing?

Code: Select all

#turbo 
#define INIFile "c:\macroquest\release\macros\buffs.ini"
|#define MyPrivChannel "mypriv"
#chat chat

Sub Main
  /zapvars
  /declare Bufflist array2
  /declare Buffcount global
  /declare Chatchannel global
  /declare Gsymbol global
  /declare Gbot9 global
  /declare Gfos global
  /declare Gsta global
  /declare Gsot global
  /declare Gsop global
  /declare Greplen global
  /declare Gsv global
  /declare Gsd global
  /declare Gdmf global
  /declare Gvoq global
  /declare Gvq global
  /declare Ggod global
  /declare Gbss global
  /declare Gtot global
  /declare Gpos global
  /declare Ssymbol global
  /declare Spot9 global
  /declare Sfos global
  /declare Sfa global
  /declare Ssov global
  /declare Sdmf global
  /declare Sfon global
  /declare Scotr global
  /declare Srods global
  /declare Scoh global
  /declare Sdoh global
  /declare Sbor global
  /declare Crnr global
  /declare Ernr global

  /varset Bufflist(1,0) Gsymbol
  /varset Bufflist(1,1) Gbot9
  /varset Bufflist(1,2) Gfos
  /varset Bufflist(1,3) Gsta
  /varset Bufflist(1,4) Gsot
  /varset Bufflist(1,5) Gsop
  /varset Bufflist(1,6) Greplen
  /varset Bufflist(1,7) Gsv
  /varset Bufflist(1,8) Gsd
  /varset Bufflist(1,9) Gdmf
  /varset Bufflist(1,10) Gvoq
  /varset Bufflist(1,11) Gvq
  /varset Bufflist(1,12) Ggod
  /varset Bufflist(1,13) Gbss
  /varset Bufflist(1,14) Gtot
  /varset Bufflist(1,15) Gpos
  /varset Bufflist(1,16) Ssymbol
  /varset Bufflist(1,17) Spot9
  /varset Bufflist(1,18) Sfos
  /varset Bufflist(1,19) Sfa
  /varset Bufflist(1,20) Ssov
  /varset Bufflist(1,21) Sdmf
  /varset Bufflist(1,22) Sfon
  /varset Bufflist(1,23) Scotr
  /varset Bufflist(1,24) Srods
  /varset Bufflist(1,25) Scoh
  /varset Bufflist(1,26) Sdoh
  /varset Bufflist(1,27) Sbor
  /varset Bufflist(1,28) Crnr
  /varset Bufflist(1,29) Ernr
  /varset Buffcount 29

  /call Loadbufflist
|  /call Announcebuffs
|  /call Writebufflist
  :Mainloop
    /doevents
  /goto :Mainloop
/return

Sub Loadbufflist
  /declare counter local
  /for counter 0 to @Buffcount
    /varset "@Bufflist(1,@counter)" "$ini("INIFile","Buffs","@Bufflist(1,@counter)")"
  /next counter
/return


Sub Announcebuffs
  /chat #buffchannel ===== GROUP / MGB =====
  /chat #buffchannel Symbol -> @Gsymbol == Bot9 -> @Gbot9
  /chat #buffchannel FoS -> @Gfos == STA -> @Gsta
  /chat #buffchannel SoT -> @Gsot == Sop -> @Gsop
  /chat #buffchannel Replen -> @Greplen == DMF -> @Gdmf
  /chat #buffchannel SV -> @Gsv ==  SD -> @Gsd
  /chat #buffchannel VoQ -> @Gvoq == VQ -> @Gvq
  /chat #buffchannel BSS -> @Gbss == GoD -> @Ggod
  /chat #buffchannel ToT -> @Gtot == PoS -> @Gpos
  /chat #buffchannel ===== SINGLE =====
  /chat #buffchannel Symbol -> @Ssymbol == Pot9 -> @Spot9
  /chat #buffchannel Fos -> @Sfos == FA -> @Sfa
  /chat #buffchannel SoV -> @Ssov == DMF -> @Sdmf
  /chat #buffchannel FoN -> @Sfon == CotR -> @Scotr
  /chat #buffchannel Rods -> @Srods == CoH -> @Scoh
  /chat #buffchannel BoR -> @Sbor == DoH -> @Sdoh
  /chat #buffchannel R&R Cleric -> @Crnr
  /chat #buffchannel R&R Enchanter -> @Ernr
  /chat #buffchannel 
/return

Sub Writebufflist
  /declare counter local
  /for counter 0 to @Buffcount
    /ini "INIFile" "Buffs" "@Bufflist(1,@counter)" @@Bufflist(1,@counter)
  /next counter
/return

Sub Event_Chat
  /echo Made it to Event Chat
  /echo Parameters are: @Param0 @Param1 @Param2
|  /if @Param0!=="mypriv" /return
|  /if "$arg(1,"@Param2")"=="spam" {
|    /call Announcebuffs
|    /return
|  }
|  /if $arg(1,"@Param2")="write" {
|    /call Writebufflist
|    /return
|  }
|  /varset $arg(1,"@Param2") $arg(2,"@Param2")
/return
Here's the sample ini

Code: Select all

[Buffs]
Gsymbol=Player1
Gbot9=Player2
Gfos=Player3
Gsta=Player4
Gsot=Player5
Gsop=Player6
Greplen=Player7
Gsv=Player8
Gsd=Player9
Gdmf=Player10
Gvoq=Player11
Gvq=Player12
Ggod=Player13
Gbss=Player14
Gtot=Player15
Gpos=Player16
Ssymbol=Player17
Spot9=Player18
Sfos=Player19
Sfa=Player20
Ssov=Player21
Sdmf=Player22
Sfon=Player23
Scotr=Player24
Srods=Player25
Scoh=Player26
Sdoh=Player27
Sbor=Player28
Crnr=Player29
Ernr=Player30
Slice

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Wed Oct 29, 2003 10:23 am

When I try to test this, I join two channels
1) buffchannel
2) mypriv

If I send text on either channel, I never get the /echos from the event_chat sub. It's like it's never seeing the chat from those channels?
Slice

MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Wed Oct 29, 2003 10:33 am

I don't think that the default chat handler ever reads server chat channels (the private chat channels). You would need to define an event of your own ... i.e.

Code: Select all

#event mypriv "tells mypriv:"
Now I'm not sure about the text formatting since I don't have access to check right now ... so send your bot a message on the mypriv channel and look at how it comes across ... it should be something like "x tells mypriv, [in language]:" so you will want to break it down to the lowest unique string.

I believe getting the normal chat event to fire for cross server tells was requested but I'm not sure if it is there, broken or missing. I don't usually use them for bot commands.

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Thu Oct 30, 2003 3:36 am

Thanks, that got me on the right track but I'm running out of brain juice trying to get this one last problem. Currently the script hears my commands on the chat channel, spam and write work fine. The problem is when I try to add. The command I'm using is:

add Gsymbol test

So it passes this string to the event as Param0:

You tell mypriv:2, 'add Gsymbol test'

I've got it so it correctly parses it out except that my variable Gsymbol is getting set to: test' and I need it to be test without the single quote at the end.

Seems simple enough, get a $strlen and then pull out $left of $strlen - 1 but I cannot get the syntax correct for the life of me. It keeps spitting out syntax errors as I've tried different combinations of quotes, etc. Someone please take a look and fix my add command.

Code: Select all

|#turbo 
#define INIFile "c:\macroquest\release\macros\buffs.ini"
#event Mypriv "You tell mypriv"

Sub Main
  /zapvars
  /declare Bufflist array2
  /declare Buffcount global
  /declare Chatchannel global
  /declare Gsymbol global
  /declare Gbot9 global
  /declare Gfos global
  /declare Gsta global
  /declare Gsot global
  /declare Gsop global
  /declare Greplen global
  /declare Gsv global
  /declare Gsd global
  /declare Gdmf global
  /declare Gvoq global
  /declare Gvq global
  /declare Ggod global
  /declare Gbss global
  /declare Gtot global
  /declare Gpos global
  /declare Ssymbol global
  /declare Spot9 global
  /declare Sfos global
  /declare Sfa global
  /declare Ssov global
  /declare Sdmf global
  /declare Sfon global
  /declare Scotr global
  /declare Srods global
  /declare Scoh global
  /declare Sdoh global
  /declare Sbor global
  /declare Crnr global
  /declare Ernr global

  /varset Bufflist(1,0) Gsymbol
  /varset Bufflist(1,1) Gbot9
  /varset Bufflist(1,2) Gfos
  /varset Bufflist(1,3) Gsta
  /varset Bufflist(1,4) Gsot
  /varset Bufflist(1,5) Gsop
  /varset Bufflist(1,6) Greplen
  /varset Bufflist(1,7) Gsv
  /varset Bufflist(1,8) Gsd
  /varset Bufflist(1,9) Gdmf
  /varset Bufflist(1,10) Gvoq
  /varset Bufflist(1,11) Gvq
  /varset Bufflist(1,12) Ggod
  /varset Bufflist(1,13) Gbss
  /varset Bufflist(1,14) Gtot
  /varset Bufflist(1,15) Gpos
  /varset Bufflist(1,16) Ssymbol
  /varset Bufflist(1,17) Spot9
  /varset Bufflist(1,18) Sfos
  /varset Bufflist(1,19) Sfa
  /varset Bufflist(1,20) Ssov
  /varset Bufflist(1,21) Sdmf
  /varset Bufflist(1,22) Sfon
  /varset Bufflist(1,23) Scotr
  /varset Bufflist(1,24) Srods
  /varset Bufflist(1,25) Scoh
  /varset Bufflist(1,26) Sdoh
  /varset Bufflist(1,27) Sbor
  /varset Bufflist(1,28) Crnr
  /varset Bufflist(1,29) Ernr
  /varset Buffcount 29

  /call Loadbufflist

  :Mainloop
    /doevents
  /goto :Mainloop
/return

Sub Loadbufflist
  /declare counter local
  /for counter 0 to @Buffcount
    /varset "@Bufflist(1,@counter)" "$ini("INIFile","Buffs","@Bufflist(1,@counter)")"
  /next counter
/return


Sub Announcebuffs
  /chat #buffchannel ===== GROUP / MGB =====
  /chat #buffchannel Symbol -> @Gsymbol == Bot9 -> @Gbot9
  /chat #buffchannel FoS -> @Gfos == STA -> @Gsta
  /chat #buffchannel SoT -> @Gsot == Sop -> @Gsop
  /chat #buffchannel Replen -> @Greplen == DMF -> @Gdmf
  /chat #buffchannel SV -> @Gsv ==  SD -> @Gsd
  /chat #buffchannel VoQ -> @Gvoq == VQ -> @Gvq
  /chat #buffchannel BSS -> @Gbss == GoD -> @Ggod
  /chat #buffchannel ToT -> @Gtot == PoS -> @Gpos
  /chat #buffchannel ===== SINGLE =====
  /chat #buffchannel Symbol -> @Ssymbol == Pot9 -> @Spot9
  /chat #buffchannel Fos -> @Sfos == FA -> @Sfa
  /chat #buffchannel SoV -> @Ssov == DMF -> @Sdmf
  /chat #buffchannel FoN -> @Sfon == CotR -> @Scotr
  /chat #buffchannel Rods -> @Srods == CoH -> @Scoh
  /chat #buffchannel BoR -> @Sbor == DoH -> @Sdoh
  /chat #buffchannel R&R Cleric -> @Crnr
  /chat #buffchannel R&R Enchanter -> @Ernr
  /chat #buffchannel 
/return

Sub Writebufflist
  /declare counter local
  /for counter 0 to @Buffcount
    /ini "INIFile" "Buffs" "@Bufflist(1,@counter)" @@Bufflist(1,@counter)
  /next counter
/return

Sub Event_Mypriv
  /declare Length local
  /if "$arg(4,"@Param0")"=="'spam'" {
    /call Announcebuffs
    /return
  }
  /if "$arg(4,"@Param0")"=="'write'" {
    /call Writebufflist
    /return
  }
  /if "$arg(4,"@Param0")"=="'add" {
    /varset Length $strlen("$arg(6,"@Param0"")
    /varset $arg(5,"@Param0") $left(@Length-1,"$arg(6,"@Param0")")
    /varset $arg(5,"@Param0") $arg(6,"@Param0")
    /echo Length is @Length
    /echo Gsymbol is @Gsymbol
  {
/mqpause
/return
Slice

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

Post by LordGiddion » Thu Oct 30, 2003 2:23 pm

Slice
As promised my group chat parse.
Sub Event_GroupSay
/declare FirstQuote local
/declare CmdLength local
/declare Command local
/for tempvar 0 to @MasterCount
/if @MName(@tempvar)==$arg(1,"@Param0") {
/varset FirstQuote $instr("'","@Param0")
/varadd FirstQuote 1
/varset CmdLength $strlen("@Param0")
/varsub CmdLength @FirstQuote
/varsub CmdLength 1
/varset Command "$mid(@FirstQuote,@CmdLength,"@Param0")"
/call SetupTime Group @MName(@tempvar) "@Command"
}
/next tempvar
/return

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Thu Oct 30, 2003 7:12 pm

Ahhhh, I didn't use exactly your code but it did rattle the idea in my brain to break the parsing down into seperate variable instead of trying to manipulate the whole string on one line. It's working now. Thanks a ton. This is the fixed code:

Code: Select all

sub Event_Mypriv
  /declare Length local
  /declare Namestring local
  /declare Command local
  /varset Command $arg(4,"@Param0")
  /varset Command $lcase("@Command")
  /if "@Command"=="'spam'" {
    /call Announcebuffs
    /return
  }
  /if "@Command"=="'write'" {
    /call Writebufflist
    /return
  }
  /if "@Command"=="'add" {
    /varset Namestring $arg(6,"@Param0")
    /varset Length $strlen("@Namestring")
    /varset $lcase("$arg(5,"@Param0")") $left($calc(@Length-1),"@Namestring")
    /call Writebufflist
  {
/mqpause
/return
Slice