Another SIMPLE question - my density knows no bounds

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

BorealisSunbinder
orc pawn
orc pawn
Posts: 12
Joined: Thu Oct 17, 2002 6:28 pm

Another SIMPLE question - my density knows no bounds

Post by BorealisSunbinder » Wed Oct 23, 2002 3:32 pm

Special events, like the simple one below waiting for a merchant to response to you, do they just.....um, sorta happen? In all the code and macros I've looked at, these are never called, but variables are set when an event matching their definition happens. Obviously they work, even I can get them to work just fine. But, well they don't seem to follow any specific place in the macro logic............they.....well.....just sorta happen.

sub Event_Chat
/if "$p1"=="$v66" /if "$p0"~~"say" /if "$p2"~~"$char(name)" /varset v65 1
/return

Is this the case, they're always up and looking (as long as the macro is running) for a matching event, then perform whatever you put into them? Regardless of where the macro is executing at the moment?

Java
a lesser mummy
a lesser mummy
Posts: 73
Joined: Sat Jul 13, 2002 12:03 pm

Post by Java » Wed Oct 23, 2002 4:30 pm

Basically the an Event is something that occurs.
Baseball, Football, Swimming, EQ chat, an EQ death.. these are all events.

A place in your computer memory is set aside:
The Ball Field, the Stadium, the Zone your in.

The Event your waiting to happen is given a name, and that name is placed as a holder in memory.

#event Ballgame "Root root root for the home team"

The part in quotes is the text that will happen.
See.. when the event happens ( the NPC spoke to you )

Then that special corner in memory is filled with that text "Root root root for the home team"

Then it is compared for value.
Rather then selecting a specific memory address, we let that event take place at a random memory spot, so to make the comparison, we need some sort of english way to get the address that text line was assigned to.

Example:

80900000 " " (fake memory address thats empty.. Event not happen yet)

40080000 "Root root root for the home team"
( Event happend.. but address is different.)

To get the variable we want to use, out of the memory slot it's in, we use english:

Event Ballgame
This is like a handle of a Pot on the stove.. Easier to pick it up with a handle then to grab it brutely with 2 hands, yes?

So we use the handle to get the memory address where the Text was put in memory.
We compare that handle to our variable.
If the compare is True.. the memory address is not empty, it contain that text line.
If the compare is false the event didn't happen. So the handle remains .. waiting for us to grab it and compare it.

Not very good at explaining Computer stuff to Life stuff so you can start to relate. But i hope i didn't totally confuse you.

In essence the variable comparison happens when the event happens.

And since MQ is a Top to Bottom language, we take 1 pass through the macro, starting at the #event and all the way to the bottom of the written macro where we end with /return.
Only way we can check for events more then the one time we start the macro is to make the macro start all over again, from the Top to the Bottom.

Similar to reading a page.
My perception is my reality.

[url=http://www.phpbb.com/][img]http://www.mutedfaith.com/images/illusion.jpg[/img][/url]

BorealisSunbinder
orc pawn
orc pawn
Posts: 12
Joined: Thu Oct 17, 2002 6:28 pm

Post by BorealisSunbinder » Wed Oct 23, 2002 6:28 pm

Thanks for your response. My most basic question of how/when the event is evaluated / compared is answered in your statement:

"In essence the variable comparison happens when the event happens."

I understand your metaphore about handles, memory locations, etc. It was very helpful, thank you.

So we don't need to do any calls, etc. to these defined events, they happen on their own. And I take that to mean that when the event happens, the /if statement in the example is evaluated IMMEDIATELY and whatever procedures you've define to take place when that event happens, they happen right now! If your macro is in the middle of running to a loc, making bear fillets, memorizing/casting spells, whatever...that stops and macro control is passed immediately to event evaluation. If that results in a /varset fine, if it's a /call procedure, so be it. The event happens, evaluation is immediate.

Thanks again for your response so quickly and the effort you obviously put into your answer.

theafkxper
a hill giant
a hill giant
Posts: 207
Joined: Sun Sep 08, 2002 6:41 pm

Post by theafkxper » Wed Oct 23, 2002 8:28 pm

when MQ sees a certain event has happened, it stores it, and then runs whatever the event is at the next call for "/doevents" (i think its /doevents, not postitive) check readme for more info on that.

I THINK that was the answer to yoru question, not sure though ;)
- afk

BorealisSunbinder
orc pawn
orc pawn
Posts: 12
Joined: Thu Oct 17, 2002 6:28 pm

Post by BorealisSunbinder » Thu Oct 24, 2002 1:19 pm

Hah!

/doevents -- does events. Yeah, I'm a progammer. All that schoolin' is reeeeaaallly going to waste.

theafkxper
a hill giant
a hill giant
Posts: 207
Joined: Sun Sep 08, 2002 6:41 pm

Post by theafkxper » Thu Oct 24, 2002 4:12 pm

LOL, yeah I know what ya mean...

So has your question been answered or are ya still looking for something else?
-afk

AMadMonk
a lesser mummy
a lesser mummy
Posts: 77
Joined: Tue Sep 24, 2002 9:16 pm

Post by AMadMonk » Thu Oct 24, 2002 6:35 pm

Perl does events asynchronously -- no /doevents necessary *VBG*

It's good to be me somedays.

BorealisSunbinder
orc pawn
orc pawn
Posts: 12
Joined: Thu Oct 17, 2002 6:28 pm

Post by BorealisSunbinder » Thu Oct 24, 2002 10:55 pm

Nope, that pretty much answers my question. Thanks all for taking the time to respond.