Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Darkmere
Novice


Joined: 23 May 2003
Posts: 31

PostPosted: Fri Jun 06, 2003 10:43 pm   

Room Capture script question
 
Here is what I'm trying to do. When ever my window comes across the pattern in the trigger, I want it to capture the name into a variable -
i.e.
|599H 530M 346V > Menial Quarters [ S ]
I want it to capture Menial Quarters - this is the easy part..

The trouble is, I want to make a variable on the spot, to put it in -
i.e.
I want to turn the script on (mapon) and will have it prompt for a @zone variable.. Then I want the trigger below to capture all the rooms, into the name I put into that variable.

#TRIGGER {^(*)V > (*) ~[ (*)~]$} {
string=%2
#CLASS danlotest
#IF (%ismember( @string, @zone)) {#ECHO @string is already in this zone} {
@zone = %additem( @string, @zone)
#ECHO @string has been added to the list of rooms in: @zone
}
mapperused=1
#CLASS 0
}

Now when I do this, it stores the names of the rooms in to the @zone variable - instead of the name of the variable I put into @zone..

I know im a little confusing, but any help would be greatly appreciated - If you need any thing clarified, let me know.

-Darkmere
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jun 06, 2003 11:18 pm   
 
Change the trigger as per the bold text:

#TRIGGER {^(*)V > (*) ~[ (*)~]$} {
string="%2"
#CLASS danlotest
#IF (%ismember( @string, @zone)) {#ECHO @string is already in this zone} {
@zone = %additem( @string, @zone)
#ECHO @string has been added to the list of rooms in: @zone
}
mapperused=1
#CLASS 0
}

If I'm guessing right, you have a @string variable somewhere in your settings with SOMETHING in it (perhaps also with a default value set). The fact that you also see stuff getting added to @zone is because of this erroneous variable assignment.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Darkmere
Novice


Joined: 23 May 2003
Posts: 31

PostPosted: Fri Jun 06, 2003 11:24 pm   
 
The problem is not with @string, I have no trouble with storing values into it..

I have an alias that prompts for a new zone (example - Midgaard) to store the @string into.
What I want to do, is somehow modify that trigger so that @string gets stored into whatever I type into the prompt (ie. @Midgaard)

What I tried is putting the prompt to store a name (Midgaard) into the @zone var - and hoped that it would add @string into the value inside @zone (that being Midgaard)

Its really confusing to explain, but im trying my best :)

-Darkmere
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jun 07, 2003 1:00 am   
 
#TRIGGER {^(*)V > (*) ~[ (*)~]$} {
string="%2"
#CLASS danlotest
#IF (%ismember( @string, @zone)) {#ECHO @string is already in this zone} {
@zone = %additem( @string, @zone)
#ECHO @string has been added to the list of rooms in: @zone
}
mapperused=1
#CLASS 0
}

The character in red is a very common mistake. If you look around in your settings you may have a few very odd variables because of this. What actually confuses me is that you used the proper syntax in the green line. Of course Matt added the quotes which should be used mosy of the time (braces occasionally) with %1..%99 and %i..%z.
Reply with quote
Darkmere
Novice


Joined: 23 May 2003
Posts: 31

PostPosted: Sat Jun 07, 2003 1:17 am   
 
Ok, I used the syntax you suggested, and fixed that up - no more dangling variables around. But -- I'm still an a loss as to how to solve my problem.

Im trying to capture roomnames into variables.
The variables that I want to put them in change.
Im looking for a way to change the name of the variable I'm putting roomnames with an alias like (mapon NewZoneName). This will keep me from having to go in and edit the trigger everytime to accomidate a different variable(or zone) name.

For example : If I type Mapon Testzone1
I want the trigger posted earlier to do:
Testzone1 = %additem( @string, @Testzone1)

For Mapon Testzone2
I want the trigger to do :
Testzone2 = %additem( @string, @Testzone2)

Is there anyway to do this without going in and manually changing the variable everytime I switch zones?
Reply with quote
Darkmere
Novice


Joined: 23 May 2003
Posts: 31

PostPosted: Sat Jun 07, 2003 1:30 am   
 
Thats what I had in the begining - If I use that, it sets the value of @zone to Testzone1
Then - I look at a room and I get this echo
|599H 530M 346V > Menial Quarters [ S ]
Menial Quarters has been added to the list of rooms in: Testzone1|Menial Quarters

I want the Menial Quarters to be stored into Testzone1..

-Darkmere
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jun 07, 2003 6:55 am   
 
Ahh, now i understand what you want. You desire to have another level of indirection. The '=' syntax can do this, but i find it more readable when using the #VAR syntax.

Figure where to put it:
#VAR {@zone} %additem(@sting,@{@zone})

Note how the braces control the expansion of the zone. You can muck around with this in the command line with #SHOW or #ECHO to find exactly what you need if I haven't understood your wants perfectly.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net