Page 1 of 2

Anyone know how to manually /call a subroutine?

Posted: Tue Jul 16, 2013 3:14 am
by Noren
Here's the scenario:

Start a macro that is looping, waiting for me to /call a subroutine. When the time comes, I /call whatever subroutine that I want (this is done in-game through the normal chat window), and ideally the macro jumps to the line where that subroutine starts, executing exactly what I told it to.

/call works. It leaves the loop and executes the subroutine that I told it to BUT it immediately halts throwing an error that the "Flow ran into another subroutine."

Normally this error happens when subroutines are left without a /return. Despite my best efforts (so far), and what appears to be syntactically correct code, I still receive the "Flow ran into another subroutine." error when I manually /call a subroutine.

Has anyone been able to manually /call a subroutine from in-game?

Re: Anyone know how manually /call a subroutine?

Posted: Tue Jul 16, 2013 5:53 am
by Shin Noir
I haven't used this situation, but.. observing, don't go against the flow! flow with it..

code that likely will do what you're after:

Code: Select all

Sub Main
/declare doTest bool outer false
:loop
   /delay 1s
   /call TestLoop
   /if (${doTest}) /call DoTest
/goto :loop
/return

Sub TestLoop
/echo TestLoop
/return

Sub DoTest
/echo Congrats, you called a sub routine!
/varset doTest false
/return


And in your normal chat, just do /varset doTest true
kbam!

Re: Anyone know how manually /call a subroutine?

Posted: Tue Jul 16, 2013 6:38 am
by Noren
Hey Shin, thanks. I primarily wanted to be able to /call a subroutine from chat specifically so that I could pass multiple arguments to it. I considered the route you suggested and I think ultimately I'll end up doing that since I don't think /call will work out. To get the nearest-to-desired-functionality I thought to use a one-dimensional array.

I would like to set multiple array element values in one line. If I were to do it in PHP I'd simply do $array = array(1, 2, 3, 4); and boom I've essentially set 4 variables in one line. Poring over the MQ2 documentation, it appears I can only set one array element at a time. Is that correct?

Thanks

Re: Anyone know how manually /call a subroutine?

Posted: Wed Jul 17, 2013 12:50 am
by canatel
My solution to this was a little different. I use events to control the macro.

Code: Select all

#event Roar "#*# tells you, 'Roar!'"

Sub Main
   :loop
      /delay 1s
      /doevents
   /goto :loop
/return

Sub Event_Roar
   /g Congrats, you called a sub routine!
/return


Re: Anyone know how manually /call a subroutine?

Posted: Wed Jul 17, 2013 12:55 am
by Shin Noir
You're doing some funky stuff, but you can also go

Code: Select all

/multiline ; /declare Rawr[2] int local ; /varset Rawr[1] 99 ; /varset Rawr[2] 12 ;

results are like
/echo ${Rawr[1]}
99
/echo ${Rawr[2]}
12


I think canatel's solution may work for your argument passing via Events

Re: Anyone know how manually /call a subroutine?

Posted: Thu Jul 18, 2013 7:52 am
by Grey
I use a never ending loop in the sub main and call routines in order of precedence. Trial and error got me to where I am now.
As for manually calling a routine create a EQBC sub that you can pass a command to with arg's.
Off top of my head example that may or may not work

/bc call custom Arg3

Code: Select all

#Event EQBC "<#1#> #2#"
#Event EQBC "[#1#(msg)] #2#"
#Event EQBC "[MQ2] #2#"
Sub Event_EQBC(EQBCSay,EQBCSender,EQBCCommand)
/if (${EQBCCommand.Arg[1, ].Equal[Call]} && ${EQBCCommand.Arg[2, ].Equal[Custom]}) /call Custom ${EQBCCommand.Arg[3, ]}
/return

Would call your custom sub and pass arg3 into it

Not online in any server so I cant go echo this to get correct syntax but that should give you an idea.
Double check your code that you have /doevents in proper places and in some areas you may need to flush the que.

Re: Anyone know how manually /call a subroutine?

Posted: Fri Jul 19, 2013 3:36 pm
by canatel
I... think... you're doing... the same thing... that i do... but in a more difficult way that's more dynamic and works through passing arguments.(which i didn't know how to do)

*Bookmarked for later review when I'm online and can play with it*

Re: Anyone know how manually /call a subroutine?

Posted: Sun Jul 21, 2013 4:42 pm
by Grey
canatel wrote:I... think... you're doing... the same thing... that i do... but in a more difficult way that's more dynamic and works through passing arguments.(which i didn't know how to do)

*Bookmarked for later review when I'm online and can play with it*


I have a very dynamic macro these days. Very little is hard coded in the sense that I can change anything on the fly without having to /endmac edit the file and restart it.
That and the sub eqbc I use has over time grown to handle pretty much anything I need it to that is not in the main loop checks.

Re: Anyone know how to manually /call a subroutine?

Posted: Sun Jul 21, 2013 6:54 pm
by Noren
Thanks for the reply, guys. I had originally wanted to avoid chat events. Passing commands and arguments through chat seemed spammy and down-right silly sending them through the server when I already have my toons connected to one another through EQBC Server locally. That is until Grey pointed out that macro event listeners also parse EQBC Server chat! Perfect.

I'll be writing these macros following Grey's advice (thank you Grey).

Here's the functionality layout:

[1] Manually target a mob
[2] Engage the mob (let's assume from a tank)
[3] /bc Heal ${Me.ID}
This causes every character connected to EQBC with a valid event listener to trigger an event sub-routine passing the sender's ID as an argument. A healer receiving this message would /target ID [tank id] and then begin to heal the tank. My dps would not have any chat event listeners for 'Heal' so they would do nothing.
[4] /bc Attack ${Target.ID} ${Me.ID} ranged
This causes every character with event listeners matching 'Attack' to /call Attack, and begin dps on the specified Target.ID but also accepting Me.ID so that action can be taken in the event of a tank death or any other edge case, along with an argument specifying 'ranged' so that no melee will go in.
[5] At some point in the script, we need to halt dps so I then /bc StopDPS. This stops all dps but not healing, so that the tank doesn't die.
[6] If I need to move the raid to a new location while still tanking the boss in one spot, I could /bc Moveto locx locy ${Zone} where all characters in the specified zone (anyone outside the zone would ignore that command) would move to the locs specified.

I believe Grey's method can accomplish all this. Sorry if I wasn't clear from the start about what I was looking for, but Grey definitely hit the nail on the head. I wish it was as simple as /bca //call Moveto locx locy ${Zone}, but hey I didn't write MQ2 so I have no grounds to complain about what it can't do =).

To Grey: why do you pass 'call' as a parameter of your chat event? I can't yet think of any thing BUT call that I would want my characters to do, so I don't understand why you bother passing it unless you're also doing /varset commands through EQBC chat events (but you could skip chat events all together and simply /bca //varset). Would you mind sharing?

Re: Anyone know how to manually /call a subroutine?

Posted: Sun Jul 21, 2013 11:26 pm
by Shin Noir
Your entire list: modbot + hotbuttons on my "commander" (bard, with a copy on my SK) for me.