Call on numbered aliasas

Posted by WRTIII on Sun 08 Jun 2003 11:06 PM — 9 posts, 32,960 views.

Canada #0
Grrrr So many problems trying to do so many things too..

I've setup Aliasis from G1 to G65

Each one is enabled
Ignore Case
Expand Varible
and in the group GUIDE

And each one sends a message such as

G1 = TELL @GUIDEE Welcome to The Game
G2 = TELL @GUIDEE My name is @myname. I will be your guide.

etc.

but the problem now is sitting there typing G1 to G65 without forgetting where you were at. holding afew conversations and walking around

Kinda hard. :(
So I tried to make aliases called GNEXT and GPREV that would take the varible GNUM and add 1 to it and send G# to the mud so I could just type GNEXT over and over till I get to 65
and then have a GRESET command to reset it back to the beginning.
As well as GPREV in case I need to repeat something.

Is there anyway to add a world.note to an alias so that It will show which number it is as well?

Thanks,
WRTIII
Australia Forum Administrator #1
What I would do is put the messages into variables, not aliases, with a logical name (like you have), eg.

MSG1 = Welcome to The Game
MSG2 = My name is @myname. I will be your guide.

Then your "gnext" alias would take a message number (you could store one for each person you are helping).

Something like this:


'
'  find where this person is up to
'

num = world.GetVariable ("guidee_" & name)

'
'  first time - num will be empty
'

if IsEmpty (num) then
  num = 1
end if

'
'  Get the appropriate message
'
msg = world.GetVariable ("MSG" & num)

'
'  tell the player
'
world.send "Tell " & name & " " & msg 

'
' add 1 to message number, save for next time
'
num = num + 1

world.SetVariable "guidee_" & name, num



For instance, if you were helping Nick the variable "guidee_Nick" would be 1 (then 2, 3 and so on).
Amended on Tue 10 Jun 2003 07:49 AM by Nick Gammon
Canada #2
I am still lost somewhat I think I pretty much understand what you mean.. but..


Ok So for now I manually make the varible Guidee_Nick

and I have an Alias GNEXT which calls on Sub routine GNEXT

Sub Gnext (a, b, c)
'
' find where this person is up to
'

num = world.GetVariable ("guidee_" & name")

'
' first time - num will be empty
'

if IsEmpty (num) then
num = 1
end if

'
' Get the appropriate message
'
msg = world.GetVariable ("MSG" & num)

'
' tell the player
'
world.send "Tell " & name & " " & msg

'
' add 1 to message number, save for next time
'
num = num + 1

world.SetVariable ("guidee_" & name, num)

I just copied and pasted for the time being but now when I type Gnext, How does it know who I am guiding? Ack I am confused lol I know I am a pain in the ass.

First error I got with that though is...
Error number: -2146827255
Event: Execution of line 144 column 44
Description: Unterminated string constant
Line in error:
num = world.GetVariable ("guidee_" & name")
Called by: Immediate execution

So I took the third " out..

Then I get

Error number: -2146827244
Event: Execution of line 169 column 42
Description: Cannot use parentheses when calling a Sub
Line in error:
world.SetVariable ("guidee_" & name, num)
Called by: Immediate execution


And it is there that I am stuck.. and now confused because I've been trying to figure this darn this out and not getting anywhere.. I wish I knew what I Was doing lol... please help
Thanks

WRTIII


Oh, If I remove the brackets from line 169 I get...

Error number: -2146827274
Event: Execution of line 170 column 1
Description: Expected 'End'
Line in error:

Called by: Immediate execution
Canada #3
Ok I am using right now...

Sub Gnext (a, b, c)
'
' find where this person is up to
'

num = world.GetVariable ("guidee_" & name)

'
' first time - num will be empty
'

if IsEmpty (num) then
num = 1
end if

'
' Get the appropriate message
'
msg = world.GetVariable ("MSG" & num)

'
' tell the player
'
world.send "Tell " & name & " " & msg

'
' add 1 to message number, save for next time
'
num = num + 1

'world.SetVariable ("guidee_" & name, num)

'
' Had to comment this out because I get the error,
'Description: 'Cannot use parentheses when calling a Sub
'

End Sub

But When I type in my alias GNEXT Now It sends to the world

*
Tell
You chatter away to yourself.
*

So it's sending the tell part... now it just needs to send the name of who to send it to and the correct MSG#

I will keep trying to get it working but this is as far as I have gotten so far.
Thanks for any help

WRTIII
Australia Forum Administrator #4
Well, I gave you a snippet, not the whole thing. For instance, you need to establish the name.

I was imagining you would have an alias like this:

gnext *

So you might type "gnext nick". Then the alias gets the name from wildcard 1, eg. like this:


sub gnext (name, output, wildcards)

dim name

  name = wildcards (1)

' then the rest I did before

end sub


You don't need to manually set up the variable first, the snippet I gave you takes care of that by checking for an empty guidee number, if it is empty the variable doesn't exist, so it starts at 1.
Australia Forum Administrator #5
Sorry about the other errors, that was untested code.

There was a " too many, you are right, and in the "setvariable" line you don't need the brackets, as the error message said. I have fixed my earlier post.
Canada #6
Thank you I got it working great now.

sub gnext (nme, output, wildcards)

Dim name

name = wildcards (1)
num = world.GetVariable ("guidee_" & name)

if IsEmpty (num) then
num = 1
end if

G = world.GetVariable ("G" & num)

world.send "Tell " & name & " " & G

num = num + 1
world.SetVariable "guidee_" & name, num

End Sub


The only problem I came across it that using the varible name and name in the sub part seemed to cause an error so I changed it in the sub to NME

If that is bad or going to cause a problem please let me now I do now understand that part of the sub except the last part is what the any wildcards will be called in that sub I believe.

Thanks again
WRTIII
Australia Forum Administrator #7
Ah yes, more untested code.

You are right, you can't use "name" in the two ways I did. You are right to rename one of them.

I didn't quite understand your last question - the wildcards are passed into the sub as an array, which is the third argument. Thus wildcards (1) is the first wildcard.
Canada #8
Yes but if I was to do

Sub (A, B, C)
then
C (1)

would be the first wildcard correct?


As in I can name the wildcard arry anything I want and it will work the same as long as I use the same name throughout the whole sub.