This code has been rigorously tested, and while I cannot say it is 100% bug free, I will say that I have yet to run into a bug.
PAGE ME
Okay, now that wasn't so hard, was it? Yes, I quite realize that there has been NO coding yet. We're getting there. We are. Our NEXT step is to pull up the TRIGGERS window in MUSHclient. Click on the button that looks like a bunch of lines, with an arrow pointing to the highlighted line. *click* Now, click on ADD trigger. The Edit Trigger window will pop up. (See figure 1-1)
You sense that Bobo_The_Evil_Clown is looking for you in hell.
PAGE ME=:smiles inanely.
In a page-pose to you, Bobo_The_Evil_Clown smiles inanely.
PAGE ME=Sending text!
Bobo_The_Evil_Clown pages, "Sending text!" to you.
WOW, there's a lot of crap in this window. It's there for a reason, but don't worry, we won't be using much of it. Briefly, here's an explanation of the stuff we WILL be using.
|
![]() Figure 1-1 |
You sense that * is looking for you in *.We give it a label by typing BlankPage in the LABEL text box, and click on OK! (We'll be coming back to give this thing a script after we've written the script.)
Now, we add two more triggers, label them (call them GotPage and GotPagePose), and close out the triggers window. It's time to start coding.
First, I'll display the code, then comes the line-by-line analysis.
sub GotPage(arName, arOutput, arArgs)
Alllllllrighty then! Looks simple enough, huh? Let's see what it does. The first line is our SUBROUTINE definition. It simply states that the name of the subroutine is GotPage and that the arguments passed to it are arName, arOutput, and arArgs. (These three arguments are required whenever a script is run by a TRIGGER or ALIAS. If it's run by a MACRO, only arName is required.
dim PagePerson, PageMessage, Response
PagePerson = arArgs(1)
PageMessage = arArgs(2)
Response = "<CANCEL>"
Response = InputBox("You were paged by " & PagePerson & ":" & chr(13) & " -- " & PageMessage,"You Recieved a PAGE!")
if Response = "<CANCEL>" or Response = "" then
world.note "Page ignored."
else
world.send "page " & PagePerson & "=" & Response
end if
end sub
Our second line defines a number of internal variables. PagePerson is the person who sent the page, PageMessage is the message or page-pose they sent, and Response is your response to them.
Now we start getting into the code itself. The arArgs argument is an array that contains the text that was in the place of the wildcards (*) in our trigger (or alias, but that's another lesson). They're in consecutive order, so assuming your MU* uses a similar page convention to SMT Muck, the first one will contain the NAME of the person paging you, and the second one will be the message or pose. Therefore our next two lines get the information out of there and put it in our local variables.
The line after that sets the default value for our response to <CANCEL> so we can identify when the user has clicked on the CANCEL button.
Next is our InputBox, which notifies us of a message and waits for a response. The usage for the InputBox function is as follows:
Local_String_Variable = InputBox(Box_Message [, Box_Caption][, Box_Default_Text])
Note that the default text is the THIRD argument passed, and therefore MUST have two commas before it, even if you don't pass a caption. In any case, the next line of the code checks to see if a response was actually made. If not, it makes a note to the user stating "page ignored." If so, it sends the response as a page to the person who paged you.
Well, that does it for messages and page-poses. Now on to the blank pages. Here comes the code.
sub GotBlankPage(arName, arOutput, arArgs)
You'll notice right off the bat that I didn't use the local variables PagePerson and PageMessage. There's a reason for that. The reason is that I'm lazy. I decided to leave the code as is to show you how UGLY scripting can get if you don't use meaningful variable names. And NOT because I'm lazy. Honest.
dim lvResponse
lvResponse = msgbox ("You got paged by " & arArgs(1) & " who would like you to meet him/her at " & arArgs(2),vbYesNoCancel, "Page Summon Recieved!")
if lvResponse = vbYes then
world.send "page " & arArgs(1) & "=I'm on my way!"
elseif lvResponse = vbNo then
world.send "page " & arArgs(1) & "=Sorry, can't make it."
else
world.note "Page ignored."
end if
end sub
Now, you'll also notice that I used the variable prefix [lv] on my variable lvResponse. The reason I didn't do this earlier is that I forgot. Sue me. The prefix doesn't do anything, it just reminds me that this is a LOCAL VARIABLE (hence "lv") and not a GLOBAL or MODULE variable. Not that I use any global or module variables here. Or ever. I hate 'em, personally. If you want to pass information around, use ARGUMENTS, people. And I mean that in a social context, not a programming one... or is it the other way around?
</RAMBLE>AAAAnyway. I'll keep the explaining to a minimum. Suffice it to say that this subroutine uses the MessageBox function and the built-in globals vbYesNoCancel, vbYes, and vbNo.
USAGE OF MessageBox:
Result = MessageBox(Message_Text[, Buttons][, Caption])or,
So, we alert the user of a page, wait for them to respond, and either send a message or ignore it, much like the original GotPage script. Now to link our scripts to our triggers.
MessageBox Message_Text[, Buttons][, Caption]