• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->
  • There is a suspension wave happening, we're still gathering information. Please keep regular discussion to Suspension MegaThread and please consider submitting a Suspension report to RG.

need guide (1 Viewer)

clrplr

New member
Joined
Jul 2, 2005
RedCents
does anyone have a guide on how to make your own macros? i thought i saw one b4 but not sure...
 
Pound Commands

This is all quoted from Mq2 Wiki

Pound Commands

Pound commands are pre-execution commands that are not run during the macro.

#turbo [#] This will prevent bad macros from locking up the client by allowing you to limit the number of commands per iteration. The default is 20, while the maximum value is 40. A value of 1 will essentially disable #turbo.

#turbo is active with the default of 20 in all macros even if you do not use #turbo in your macro.

#define replaceme replacement Replaces all occurrences of replaceme with replacement throughout the macro.

Example #define Me charactername When the macro executes, when Me occurs, it will be replaced with charactername

#include "filename" Allows you to use functions from another macro file by using /call.

Normally the filename extension .inc is used to indicate that it is an include file, but you may use any extension name that you like.

Subs present in an include file are accessible by the calling macro as if the Sub existed within the calling macro.

#event eventname "string" Creates a custom event (Sub Event_eventname) that occurs whenever string is sent to the chat box.


Example #event SpellFizzle "Your spell fizzles!"

Matching Sub: Event_SpellFizzle


A matching Sub must be used. Custom events are further explained in Subroutines


Please see Custom Events for additional information about events.
 
Subroutines

Subroutines

Every macro has a Sub Main that defines the macro's entry point. Sub Main accepts parameters if desired.


Sub Main . code . /return


Additional Subs can be defined and used with /call. /return will return to the statement after the /call.

All subroutines and Sub Main accept passed in parameters. Some information you need to remember is: You do not have to define parameters for a sub Parameters passed to a Sub without defined parameters will default to Param0, Param1, ... Paramn Default parameters are of type string If you define the parameters of a Sub, the parameters can be of any data type that exists in MQ2DataVars If the type of a defined parameter is not given, it will default to string When you define the parameters, you may use the parameter names as variables in the sub If parameters are undefined, you would use Param0, Param1,...Paramn as the variable names Sub Main(int MyParam1, MyParam2, float MyParam3) /if (${Defined[MyVar2]}) /goto :DoThis /call MySub ${var1} ${var3} /echo This value was returned from MySub: ${Macro.Return} /return

Sub without defined parameters

Sub MySub /if (${Defined[Param0]}) /goto :DoThis . execute this code when /call MySub is executed. Parameters are not necessary. . /return [value|${varname}]

Sub with defined parameters

Sub MySub(int MyParam0, bool MyParam1, MyParam2) . execute this code when /call MySub is executed. . /return [value|${varname}] The above Sub has 3 Parameters, MyParam0 is an int type, MyParam1 is a boolean type , and MyParam2 is a string type.

Special subroutines (Chat, Timers, and Custom) starting with Event_ are used in conjunction with the command /doevents


Chat Events


Sub Event_Chat[(ChatType,Sender,ChatText)]

ChatType : Channel of message (tell, group, say) Sender : Name of the person who sent the message ChatText : Text they sent


Example

Sub Event_Chat[(ChatType,Sender,ChatText)] . This code is executed when /doevents finds(queues) text in the channel defined by #chat "channel" . /return [value|${varname}]


Timer Events


Sub Event_Timer[(Timer,OriginalValue)] Timer: Timer that fired OriginalValue : Value timer was originally set to Example

Sub Event_Timer[(Timer,OriginalValue)] . This code is executed when /doevents detects(queues) any defined timer reaching 0 . /return [value|${varname}]

Retrieved from "http://www.macroquest2.com/wiki/index.php/Subroutines"
 
Custom Events

Custom Events

The new Custom Event system requires that you use the entire line of chat, BUT allows for making sections of the line a parameter.


Old Event system

Event SelfEcho "[MQ2] Genbot "
Here is what the new Event look like:

Event SelfEcho "[MQ2] Genbot #1#"
The #1# in the middle of the match text is what you use to indicate "this part of the message should be given to me in a parameter". The number between the # signs says what parameter number you want this to be in your Sub Event_Whatever.

The first parameter in the sub will be the entire line itself... 1 starts AFTER that. e.g. this event could look like this:

Sub Event_SelfEcho(string Line, string Command)
Imagine this is the text that matches the event text:

"[MQ2] Genbot THIS IS MY COMMAND"
The two parameters are:

Line=[MQ2] Genbot THIS IS MY COMMAND
Command=THIS IS MY COMMAND
The system also allows you to grab a MQ2Data value like this:

#Event SelfEcho "[MQ2] Genbot |${Me}| #1#"
The system itself has no idea that MQ2Data even exists, and is just looking for the | or #.

MQ2 makes it parse what's inside the || as MQ2Data when the system checks to see if the event is a match.

So, this event would only hit when, if ${Me} is currently "Lax", the message starts like..

"[MQ2] Genbot Lax whatever"
Notes:

Because this system lets you pick the parameter number of any portion of the message, some parameters might not get made (e.g. wont be ${Defined}... it's up to you to make sure you get the ones you need defined. The MQ2Data is not immediately parsed when the event is made, it gets parsed when the system checks to see if the event is a match. If you need to SKIP a portion of the text (dont care about it, just need to ignore part of the text that might not match, whatever), you can use #*#. Example

Event SkillUp "You have become better at #1#! (#2#)"
Sub Event_SkillUp(SkillUpText,Skill,int Amount) /popup ${Skill} increased - ${Amount} ... /echo ${Skill} increased - ${Amount} ... /return

SkillUpText = "You have become better at #1#! (#2#)" Skill = Parameter 1 = #1# Amount = Parameter 2 = #2#

Also, you can have custom events that record all chat of a certain type, such as tell via the #Chat pound command

#Chat tell
These are activated with the Sub Event_Chat which takes the parameters of the type of chat (ie. tell), the sender, and the message text

Retrieved from "http://www.macroquest2.com/wiki/index.php/Custom_Events"
 
MQ2DataVars

MQ2DataVars

MQ2Data was designed so that accessing information could be done utilizing a uniform system. User variables are utilized as MQ2Data Top-Level Objects.

About Types

User variables can be declared as any MQ2DataVars type, however there is no reason to create a variable that is an independent type such as the macroquest type, although it will work.

Scopes

There are three scopes used by macros.

global Variables of global scope ALWAYS exist until they are deleted or macroquest ends

outer Variables of outer scope exist while a macro is running

local (default) Variables of local scope only exist while within a macro function or "Sub"

Commands specific to user defined variables

/declare varname|varname[array extents] [type] [local|global|outer] [defaultvalue] Creates a variable within a particular scope and of a particular type. The parameters must be given in order, but any after varname may be skipped to use the default.


The default type is string The default scope is local The default value is nothing (empty string, or 0) These variables can be of any type that exist in MQ2DataVars. The variable will then have access to the members of that type.


Examples

/declare MyVar int outer
Creates an int variable named MyVar that exists while the macro is running

/declare MyVar local
Creates a string variable named MyVar that exists within the Sub it was created in

/declare MyTimer timer outer 3000
Creates a timer named MyTime that is set to 3000 at creation and exists while the macro is running

Arrays

To create an array, attach brackets to the end of the variable name and place in it the number of elements per dimension.


Array Examples

MyArray[10] int Creates a single-dimension local array of int with 10 elements (1-10) all 0

MyArray[10,10] int outer 5 Creates a 2-dimensional 10x10 elements(1-10,1-10) int array of scope outer with all values of 5

MyArray[4,5,6] string outer UNDEFINED-ARRAY-ELEMENT Creates a 3-dimensional array with 4x5x6 elements (1-4,1-5, 1-6) with UNDEFINED-ARRAY-ELEMENT in each location There is no limit to the number of dimensions or the number of elements in each dimension, but use your own good judgement.

Note: You cannot make an array of timers.

/deletevar varname [*|global]
Deletes the variable varname. Using * global will delete all global variables.

/varset varname [newvalue]
Sets a variable directly to a new value. Keep in mind that the type itself may reject this value depending on what you give it. To clear the value of the variable, you may omit the new value.


Examples

/varset MyString ${MyString}stuff
concatenate a string variable

/varset MyString stuff${MyString}
inserts stuff at the front of ${MyString}

/varset MyInt 123
Sets MyInt to 123

/varset MyTimer 123s
Sets MyTimer to 123 seconds

/varset MyFloat 1.23
Sets MyFloat to 1.23

/varset MyIntArray[n] 123
Sets array element n to 123




/varcalc varname formula
Sets a variable directly to the numeric result of a calculation. Keep in mind that the type itself may reject this value depending on what you give it. This will NOT work on strings!


Examples

/varcalc MyInt 1+2*2+1

/varcalc MyInt 1+(2*2)+1

/varcalc NumBuffSlots ${Me.FreeBuffSlots}+${Me.CountBuffs}



/vardata varname newMQ2Datavalue
Sets a variable directly to the end result of a MQ2Data string. To use this, do NOT put ${} around the outer data to parse This is most useful for when you want to keep the result of something instead of trying to make the variable accept a string with /varset.


Example

/vardata MyFloat Math.Calc[${Me.X}+${Me.Y}]
Parsing

It is important to note that parsing of variables is performed from the inside to the outside, so any ${} inside your MQ2Data usage get evaluated before continuing.


Example

${MyString${MyVar}}
The parser first evaluates ${MyVar}. If MyVar's value is 1, this is then ${MyString1}. ${MyString1} is then evaluated, giving the value of whatever MyString1 is. ${${MyString}} will get the value of a MQ2Data query stored in MyString. This could be Me.Buff[1], or a variable name, or anything that is valid inside ${}. There is no limit to this recursion.

${${${${${${${${${${MyString}}}}}}}}}} will evaluate inside to outside until there is nothing left to evaluate.

This is also true for arrays: ${MyArray[${MyInt}]} has no problems.

Retrieved from "http://www.macroquest2.com/wiki/index.php/MQ2DataVars"
 
need guide

Users who are viewing this thread

Back
Top