With the current script you would add more function calls into the loop.
Example:
Code: Select all
#NoEnv
SetBatchLines, -1
Loop
{
eqLog("Tex tells the group, 'Assist me", "1", 500, 1500)
eqLog("Tex tells the group, 'Follow me", "2", 500, 1000)
}
eqLog(str, key, min, max) {
FileRead, eqlog, C:\P2k\Logs\eqlog_Rex.txt
if InStr(SubStr(eqlog, InStr(eqlog, "`n",, 0, 2) + 1), str)
{
rndSleep(min,max)
Send % key
}
Sleep 1000 ; Note: change to adjust speed of script
}
rndSleep(min,max)
{
Random, sleeptime, min, max
Sleep, sleeptime
}
The only bad part now would be the log file is read each time you want to check a trigger.
(This is why its important to state what the intentions of the script is before you start, not a problem just saying)
Now that we know we want any number of triggers we can change the script to handle an array of objects which will make things easier.
Example:
Code: Select all
#NoEnv
SetBatchLines, -1
triggers := []
triggers.push( {"str": "Tex tells the group, 'Assist me", "key": 1, "min":500, "max": 1500, "delay": 1000} )
triggers.push( {"str": "Tex tells the group, 'Follow me", "key": 2, "min":500, "max": 1000, "delay": 1000} )
; Add more triggers using above format (I could put all in one line but this should be easier for you to follow)
Loop
eqLog(triggers)
eqLog(obj) {
FileRead, eqlog, C:\P2k\Logs\eqlog_Rex.txt
for each, trigger in obj
if InStr(SubStr(eqlog, InStr(eqlog, "`n",, 0, 2) + 1), trigger.str)
{
Random, sleeptime, trigger.min, trigger.max
Sleep, sleeptime
Send % trigger.key
}
Sleep trigger.delay
}