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
Jim Vance
Beginner


Joined: 07 Dec 2006
Posts: 16

PostPosted: Tue Jan 23, 2007 6:48 pm   

Room Script Bug
 
I am having a bit of an issue with my Automapper. Here's the scoop:

I wanted to be able to go to a room on my mapper, and from there, do a variety of quests. I also wanted to use basic alias patterns, rather than have a list of 300+ aliases for different quests. I set it up so that whenever I went to one of these "quest node rooms", a line would show up on my MUD output window that says "Quest Hotspot". If I type the alias "quest" in that room, it would then show a list of available quests in a window called "Guide" along with some easy-to-use aliases to go do the initial parts of the quest. So here's a sample of the room script

Code:
#SHOW ~<color peru>Quest Hotspot:~</color> ~<color springgreen>Type ~"quest~" for list ~</color>
#ALIAS quest {
  #WIN Guide ..
  #WIN Guide ~<color yellow>~<u>Available Quests~</u>  (Rivendell)~</color>
  #WIN Guide . 
  #WIN Guide ~<color white>Quest 1
  #WIN Guide j1 - do blah blah
  #WIN Guide .
  #WIN Guide ~<color white>Quest 2
  #WIN Guide h1 - do blah blah blah
  #WIN Guide .
}
#ALIAS j1 {#WALK 10680;do blah, blah, blah}
#ALIAS h1 {#WALK 20653;do blah, blah}


Now, most of the time, this works just fine. When I go into the room with the script, it creates the aliases, and when I leave the room, it gets rid of them. However, sometimes I go to these rooms and the aliases get created in my Settings Directory. Then when I go to a room in some other area, I might get the "Rivendell" aliases shown above. Is there some way I can fix the script so that they only exist when I am in the rooms after I type "quest" and no aliases get saved to my Settings Editor? Any ideas on why this is happening?

Thanks for any help.

Jim
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Jan 23, 2007 8:13 pm   
 
Sounds like a ZMud bug to me.

How about doing a work-around by storing things in a variable and using %roomnum()? I'm reasonably sure you could get it down to one variable and one alias (total, not per room)... I'll try and make up an example of what I'm thinking of...
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Jan 23, 2007 9:19 pm   
 
OK, here's something quick I put together. I did the best I could to display the variable in a legible format, since db variables do -not- show well on the forums. In reality it's a single db variable with two keys per quest room, one which is the roomnum+quests and the other which is roomnum+msg.

The first part (quests) has a string list with each item being the list of commands for one quest.

The second part (msg) is the message you want to show with the room name, list of commands, etc. I did it in two ways (you can see both). The first one is just a straight message which is executed as is. The second uses a second alias (showquest) which imho is worth it, since it makes the entire thing much easier to read... you just pass the alias two arguments, first of which is the room name and second is a string list of short descriptions for quests, in order.

You would still put {#show Quest hotspot!} or whatever in your roomscript, but that would be all.

The quest alias just pulls it all together, either showing the msg or doing the quest depending on what you enter. I wasn't able to think of an easy way to get letter+number combinations for different quests but I think just simple numbers should be doable, you can add in more comments about what each quest is like in the msg part if you need to.

I also didn't add in colour formatting or things since I'm running out of time atm, but it should be fairly simple.

Annnd, the main problem I can see is something that your current script would have problems with, too--it sends the #walk and then immediately "do blah". You'll possibly need a timer or something, if you don't have a better way in your current script. (Possibly something with @onwalkend...hm.)

Code:
#ALIAS quest {#if %1 {#exec @{quest_rooms.%roomnum( )quests.%1}} {#exec @{quest_rooms.%roomnum( )msg}}}
#ALIAS showquest {#show ..;#show Avaliable Quests %1;#show .;#loop %numitems( %2) {#show {%i - %item( %2, %i)};#show {.}}}

Code:
#VAR quest_rooms

266quests          (#show blah1;do blah1)|(#show blah2;do blah2)
266msg             #show {..};#show {Avaliable Quests (Rivendell)};#show {.};#show {Quest 1};#show {1 - do blah1};#show {Quest 2};#show {2 - do blah2};#show {.}

261quests          (#show blah1;do blah1)|(#show blah2;do blah2)
261msg             showquest {Rivendell} {do blah1|do blah2}
Reply with quote
Jim Vance
Beginner


Joined: 07 Dec 2006
Posts: 16

PostPosted: Sat Jan 27, 2007 6:18 pm   
 
So is this two examples of how to do one thing? I appreciate the info and help, and I can see how it will make less problem for the client, but I just don't get all the details. Are the numbers on the second batch of code corresponding to room numbers? I don't see where the actual aliases for executing the quests are either. Help me decipher this script a bit?
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Jan 27, 2007 11:51 pm   
 
Ah, yes, sorry, the numbers on the left (in the key values--266 and 261) are room numbers.

It's two examples, kind of, honestly they're not -that- different, just changed from making the "msg" the entire thing for each room to making it just what changes and using an alias to format it. It's really just aesthetics and keeping clean script. Basically moving what you can from the var, which will ultimately contain one entry per room, to the aliases which contain one entry total.

The alias for executing the quest is the "quest" alias, if you just do "quest" with no arguments it'll execute the ###msg (which would just show you the message). If you do "quest #" then it'll execute the matching quest from ###quest... it isn't very large since almost all of the actual code that you would want to execute goes into the variable, so all the alias has to do is pick out the one you want and run it through #exec.

Anyway, since you can easily access an element in a string list by number, I just used that to make things simpler--quest 1 for each room is the first item in the string list in ###quests, quest 2 is the second, and so on. (You will need to make sure the numbers that you put in for the messages line up with the order of the quests in the ###quests section.)

v.3: Not much changed, streamlined the variable a little bit and moved some stuff into the quest alias--again functionally the same, just moved around a bit where things were being done. Also added error checking to the quest alias...just because. -grin- In happy news, you should be able to copy-paste the entire script block into your command line and get both aliases and the var correctly, change the room numbers in the var to your current map room and go offline (unless you really want to send test strings to your mud), then try quest, quest #, etc.
Code:
#addkey quest_rooms 261quests {(#show blah1;do blah1)|(#show blah2;do blah2)}

#addkey quest_rooms 261msg {(Rivendale)|(do blah1|do blah2)}

#ALIAS quest {#if %1 {#if (!%null( @{quest_rooms.%roomnum( )quests.%1})) {#exec @{quest_rooms.%roomnum( )quests.%1}} {#show {Error: No such quest.}}} {showquest {%item( @{quest_rooms.%roomnum( )msg}, 1)} {%item( @{quest_rooms.%roomnum( )msg}, 2)}}}

#ALIAS showquest {#show ..;#show Avaliable Quests %1;#show .;#loop %numitems( %2) {#show {%i - %item( %2, %i)};#show {.}}}
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