Pull.mac

Post your completed (working) macros here. Only for macros using MQ2Data syntax!

Moderator: MacroQuest Developers

Chill
Contributing Member
Contributing Member
Posts: 435
Joined: Fri May 07, 2004 5:06 pm
Location: Erie, PA

Pull.mac

Post by Chill » Fri Feb 04, 2005 6:20 am

This is an ini driven random message generator. It could be adapted for most anything I suppose, but it is intended to choose a random pull message from a list in the ini.

Code: Select all

| pull.mac - 4 Feb 2005
| Written by: Chill - ini sub borrowed from robdawg
| Usage:  /macro pull [g/gu/rs/say/#] (some valid chat channel - group by default) 
| Requires: Pull.ini file (see post for format)

Sub Main 
/declare chan string outer gsay
/declare nValues int outer 1 
/call ReadINI Pull.ini "${Me.Name}" Msg
/if (!${Defined[Msg_Array]}) { 
   /echo No Messages in ini, ending
   /endm
}
/if (${Defined[Param0]}) /varset chan ${Param0}

/echo Randomly saying one of ${nValues} messages in ${chan}
/docommand /${chan} ${Msg_Array[${Math.Calc[${Math.Rand[${nValues}]}+1]}]}
/return 


Sub ReadINI(FileName,SectionName,ArrayType) 

/if (${Ini[${FileName},${SectionName},-1,NO].Equal[NO]}) { 
   /echo "${SectionName}" is not a Valid Section for FILE:${FileName}, ending macro... 
   /delay 1
   /return 
} 
/declare nArray int local 0 
/declare KeySet string local ${Ini[${FileName},${SectionName}]} 

:CounterLoop 
/if (${String[${Ini[${FileName},${SectionName},${ArrayType}${nValues}]}].Equal[null]}) { 
   /varcalc nValues ${nValues}-1 
   /goto :MakeArray 
} 
/varcalc nValues ${nValues}+1 
/goto :CounterLoop 

:MakeArray 
/if (!${nValues}) /return

/declare Msg_Array[${nValues}] string outer 

/for nArray 1 to ${nValues} 
   /varset Msg_Array[${nArray}] ${Ini[${FileName},${SectionName},${ArrayType}${nArray}]} 
/next nArray 

/delay 1

/return 
Sample Pull.ini :

Code: Select all

[Puller]
Msg1="inc ${Target.CleanName} msg a"
Msg2="inc ${Target.CleanName} msg b"
Msg3="inc ${Target.CleanName} msg c"
I had to double check my random number generator and the array numbering, but it seems to be working. I was able to get the first and last messages with no NULLs.

Next step is to build a cool ini file. :cool:

I'm looking for suggestions if anyone has seen any really cool/funny pull messages lately.

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Wed Feb 09, 2005 3:56 pm

Chill . . . this would rock as an include. Personally I run a stick macro for my sk and I am usually pulling as well. What I don't want to do is have to hotkey macro's every 30 seconds.

What would you think of converting this to an include file?

I'd give it a shot but I am out of town till next week.
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]