Moderator: MacroQuest Developers
Code: Select all
#chat tell
Sub main
Do some stuff
/return
Sub Event_chat(MsgType,MsgFrom,MsgText)
/if (${MsgType.Equal[tell]}) /dosomeotherstuff
/returnYes that does work, but it's not as refined as i am talking about. what if you want to react to tells, group say, specific channels, etc. With an improved chat event handler the abilties go up and the simplification of the scripts to their purpose becomes apparent.Kroak wrote:Typical macro...That what you're looking for? Actually... To be any other chat, you would have to add #chat chat or #chat group to the top...Code: Select all
#chat tell Sub main Do some stuff /return Sub Event_chat(MsgType,MsgFrom,MsgText) /if (${MsgType.Equal[tell]}) /dosomeotherstuff /return
See the wiki at http://www.macroquest2.com/wiki/index.p ... d_Commands
Code: Select all
#event tell CurewRGC "#1# tells you, 'Cure#*#'" Code: Select all
#chat tell
#chat ooc
Sub Event_Chat(type,sender,line)
/if (${type.Equal[tell]} && ${line.Find[blahblahblah]}) {
/dothis
} else /if (${type.Equal[ooc]} && ${line.Find[thisstuff]}) {
/dothat
}
/returnCode: Select all
#event GotTell "#1# tells you, 'blahblahblah'"
#event GotOOC "#1# says out of character, 'WTB Sword of Uber!!!'"
Sub Event_GotTell
/dostuff
/return
Sub Event_GotOOC
/dootherstuff
/returnCode: Select all
#chat channelname
Defines which channel chat events will be queued from.
Valid channels are: auc, chat, guild, group, ooc, say, shout, and tell.
Only one channel may be used.Code: Select all
#chat auc
#chat chat
#chat guild
#chat group
#chat ooc
#chat say
#chat shout
#chat tell
Sub Main
:foreverloop
/delay 2
/doevents
/goto :foreverloop
/return
/end
|type,sender,line = string
Sub Event_Chat(type,sender,line)
/echo ${type}
/echo ${sender}
/echo ${line}
/if (${type.Equal[tell]}) {
/echo ${sender} sent me a tell and it said ${line}
/if (${line.Find[give me some buffs bitchaz!]}) {
/target ${sender}
/cast "some buff of holy fucking shit"
}
}
/returnCode: Select all
#chat group
#chat tell
#chat raid
#event DoTell "#1# tells you, '#2#'"
#event DoTell "#1# told you, '#2#'"
#event DoGroup "#1# tells the group, '#2#'"
#event DoIRC "<#1#> #2#"
#event DoIRC "[#1#(msg)] #2#"
#event DoRaid "#1# tells the raid, '#2#'"
#event DoRaid "#1# tells the raid, '#2#'"
#event DoGuild "#1# tells the guild, '#2#'"
// stuff
Sub Event_DoGroup(string line, string Requestor, string Request)
|/echo Line -${line}-
|/echo Requestor -${Requestor}-
|/echo Request -${Request}-
/declare isTrusted int
| First check if allowed to command MCS
/call isValidUser "${Requestor}"
/varset isTrusted ${Macro.Return}
| If they are not a Master then check if we should resend thier tells to channel
/if (${ResendGroup} && !${isTrusted}) {
/call chatty "${Requestor}" "the group," "${Request}"
/return
}
| Added to stop above from not catching ! Trusted
/if ( !${isTrusted} ) /return
| They are Master lets check to see if it is a command
/if (${UseGroupChat}) /call ProcessRequest "${Requestor}" "${Request}"
/return
Sub Event_DoIRC(string line, string Requestor, string Request)
|/echo Line -${line}-
|/echo Requestor -${Requestor}-
|/echo Request -${Request}-
/declare isTrusted int 1
| If they are not a Master then check if we should resend thier tells to channel
/if (${ResendIRC} && !${isTrusted}) {
/call chatty "${Requestor}" "irc," "${Request}"
/return
}
| Added to stop above from not catching ! Trusted
/if ( !${isTrusted} ) /return
| They are Master lets check to see if it is a command
/if (${UseIRCChat}) /call ProcessRequest "${Requestor}" "${Request}"
/return
Sub Event_DoRaid(string line, string Requestor, string Request)
/echo Line -${line}-
/echo Requestor -${Requestor}-
/echo Request -${Request}-
/declare isTrusted int
| First check if allowed to command MCS
/call isValidUser "${Requestor}"
/varset isTrusted ${Macro.Return}
/if (${ResendRaid} && !${isTrusted}) {
/call chatty "${Requestor}" "the raid," "${Request}"
/return
}
| Added to stop above from not catching ! Trusted
/if ( !${isTrusted} ) /return
/if (${UseRaidChat}) /call ProcessRequest "${Requestor}" "${Request}"
/return
sub ProcessRequest(Requestor, Request)
// Big ass set of if statements that parses the requests and does what ever the command is.
/return

Code: Select all
#event DoTell "#1# tells you, '#2#'"
#event DoGroup "#1# tells the group, '#2#'"
#event DoGuild "#1# tells the guild, '#2#'" Code: Select all
#chat group
#chat tell
#chat raid
The reason the large macros are split into separate files is because of the forum software. Each post can only have so many lines. To reduce copy / paste errors, it was easier to split the macro into post length files. Beyond that it is personal preference to have separate functions split into separate files, though it is not my preference and certainly not others.Gnits wrote:(didnt look before i posted) I forgot this was a macro request forum... what i really meant to ask was an additional type of event type.
Event_Chat is great but the problem i have is when dealing with distributed (IE compartmentalized into include files) macros where one tries to keep things organized into those include files for debugging.
Nearly every bot type tries to do this and so does krust.
so while event_chat definately could do it if all responses were centrally managed in that one event, that is not always very convenient when looking at over all macros where there are mutltiple files.
What? From what source? From a tell? From a certain character? From your group?Gnits wrote:So i guess i am not looking for is not so much a macro (snippet), so much as a change to the source to allow for a specific event to be triggered, if the text matches FROM a specific source, not to jump to some central clearing house and from there branch off to what ever subroutine is needed.
Ok, I had not realized that but it makes perfect sense. But it also makes it easier to troubleshoot smaller sections. (At least it does for me)The reason the large macros are split into separate files is because of the forum software. Each post can only have so many lines. To reduce copy / paste errors, it was easier to split the macro into post length files. Beyond that it is personal preference to have separate functions split into separate files, though it is not my preference and certainly not others.
Code: Select all
#ChatEvent CurePerson tell "Cure me"
Sub ChatEvent (sSource as string, sFrom as string, sLine, (then the #1# type items like normal events)
So that "Soandso tells you, 'Cure me'"
triggers that event because Cure me is in the tell
