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
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Fri Nov 06, 2009 11:13 am   

multiple issues help
 
hey i want to create an auto replace using case. I want to remove all the "a" "the" "an" " ' " "," and the spaces near them from a variable:
Can this be done with #CASE ? As in search for that string at the beginning of my variable and remove it.

Thanx


Last edited by kroz on Thu Nov 12, 2009 6:09 am; edited 1 time in total
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Nov 06, 2009 3:35 pm   
 
Why not just do a %subregex? I think that existed in zMUD, though I'm not entirely convinced it was now. If not, it'll be harder to match them because replace would replace every instance, so you'd get "humn glditor" instead of "A human gladiator."

Either way, not sure #CASE is the way you want to go.

Charneus
Reply with quote
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Mon Nov 09, 2009 3:06 pm   
 
that would be nice if i knew how to use it.. which i don't :(

I'm quite a newbie when it comes to programming in zmud, especially advanced programming.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Nov 09, 2009 3:31 pm   
 
If subregex works in zMUD, you'd do something like %subregex(string, "^(?:The|An?) ") to remove the beginning portions that start with A, An, and The. Simple for the rest of it, too.

Charneus
Reply with quote
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Tue Nov 10, 2009 6:43 am   
 
This looks like a good day for questions and i've come prepared:) I'll try the subregex thing when i get home and i'll keep you updated on it.
I have questions on other things now.. Like map and child windows.

- When you are using a map to go places and you tell zmud to take you to take you through a maze it will not move. Is there a way to set up your map so that it will either take you to the area or take you to the maze?
- Can you create MXP links in child windows? So far i got to #window campaign Mob to kill %1 found in area %2 (where %1 and %2 are taken from a trigger). I want to create a hyperlink that tells the mud to take me to the area using the maps

I have more questions but we'll take it one thing at the time.

Thanx for the help Charneus!
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Nov 10, 2009 8:24 am   
 
Well, in CMUD, I've created my own 'runto' alias, similar to what Aardwolf has, but uses the mapper. Basically, I index all the starting rooms by giving them room IDs. Then I do a 'runto areaname' and if it exists, it'll run me to it. If there are more than one, it'll spit out a list. If no area has been mapped/entered, then it'll let me know.

Cool thing about is that I can type 'runto an' and it'll list all areas that have 'an' in the name. :P

As for MXP in other windows, you certainly can do that as well. You just have to indicate that you're sending the command to main window and not the child window.

Charneus
Reply with quote
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Tue Nov 10, 2009 10:23 am   
 
here's what i wanted to do:

Code:
#TRIGGER {^You still have to kill ~* (*) ~((*)~)*$}
{#WINDOW campaign Mob name %1 in area %2;
#ADD cp_mbs 1;
#VARIABLE cp_lst %additem( %lower( %1), @cp_lst)}


How do i send a link to the area using mapquery instead of the area name?

And another question: is there a way of updating something in a window without resetting that window? For instance i want to change the color of the mobs that i've killed in my cp window so that i know what i already killed without resetting (when i reset the window my zmud lags me a bit)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Nov 10, 2009 6:38 pm   
 
Quote:

And another question: is there a way of updating something in a window without resetting that window? For instance i want to change the color of the mobs that i've killed in my cp window so that i know what i already killed without resetting (when i reset the window my zmud lags me a bit)


Unless it's a button caption (make the @variable the caption, then update the variable) or the status window, you have to do all the updating.
_________________
EDIT: I didn't like my old signature
Reply with quote
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Thu Nov 12, 2009 6:14 am   
 
would this match the a/an/the at the beginning of the target and the '/,/ / inside the target ?

Code:
%subregex(%subregex(%lower(%1), "^(?:the|an|a?),"),"(?'|,?),")


about the window resetting: how would you create a variable that is updated let's say by a trigger in a campaign window without #CA ? I didn't understand much from Matt's answer :(

Thanx for all the help!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Nov 12, 2009 6:59 pm   
 
Ok, first, if you want to populate variables you have to use triggers to match text from the game window. There's no other (reliable) way to do it, and even if there were an alternative triggers are still by far the easiest. Though the helpfiles are far more detailed, to make a trigger you use the #TRIGGER command (via command line, in a script, or anywhere where you type code into) or select Trigger from the New button found on the Settings Editor toolbar. Here's an example of the code version:

#trigger {this is a test.} {#say I fired}

Obviously, that's not very useful, so let's introduce you to pattern wildcards. Wildcards are placeholders that tell the parser to look for a string of characters that match the rules of that wildcard. For example, %w will match any "word" that consists only of letters. If we wanted to expand the example trigger so that we could include more things than just "test", it would look like so:

#trigger {this is a %w.} {#say I fired}

That's much better, of course, but when we want to work with data it's not very useful because it doesn't exist outside of the line of text the trigger matched on. For that, we surround the wildcard with parentheses so that it goes into one of the %1...%99 variables (each set of parentheses or use of &varname in the pattern can be referred to by %1 to %99, in order of occurrance). From there, the code in the trigger can then store the %1...%99 information into a variable.

#trigger {this is a (%w).} {MyVar = %1}

And that brings us to Buttons and Status Windows/Lines. These can use variables in their properties (to keep it simple, we'll limit this to captions for buttons and displays for the things status whatevers show). When the variable changes, the button/status whatever will instantly change. Unfortunately, the code that describe them is harder to deal with than doing the work in the Settings Editor (I could show you, but there's so much extra/useless info there that you'd get lost).

Normal windows, however, do not have that property so even if the trigger updates the variable the value printed in the window text area will not update. For that, you need one of the following:

#window windowname {text to send}
windowname:text to send
#capture windowname
#c+ windowname (combined with a later #c- to stop)

Using the example above, if we wanted to send the variable to the Stuff window the trigger would look like this:

#trigger {this is a (%w).} {MyVar = %1;#window Stuff {@MyVar}

Now, of course, there are lots of different ways you can do things, so how you do them is moreorless based on what you're trying to do. This should get you well on your way, so happy exploring!
_________________
EDIT: I didn't like my old signature
Reply with quote
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Fri Nov 13, 2009 6:20 am   
 
wow, big answer there:) Ok, i'll start exploring some captions in window on monday (i'm off for the weekend).
I pretty much knew how to use triggers, I was puzzled about the caption button.

Let's see if i got this right (for my case, described above):

Code:
#TRIGGER {^You still have to kill ~* (*) ~((*)~)*$}
{
#ADD cp_mbs 1;
#ADD cp_area 1;
#VARIABLE cp_mbs %additem( %lower( %1), @cp_mbs)
#VARIABLE cp_area %additem( %lower( %2), @cp_area)
#WINDOW campaign Mob name {%item(@cp_mbs,1)} in area {%item(@cp_area,1)};}


The trigger is good and i did understand the wildcards with (*), the beginning of the line with ^ and the end with $

do i need to put {} around the variables i send them to a window? Like i said, i can't test the code until monday.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Nov 13, 2009 6:38 pm   
 
Quote:

#ADD cp_mbs 1;
#ADD cp_area 1;
#VARIABLE cp_mbs %additem( %lower( %1), @cp_mbs)
#VARIABLE cp_area %additem( %lower( %2), @cp_area)


I'm a little puzzled by this section here, since based on what you provided it seems rather contradictory.

Quote:

do i need to put {} around the variables i send them to a window?


You need to put them around the entire text you want to send in the #WINDOW command (take the red ones out and put in the blue ones).

#WINDOW campaign {Mob name {%item(@cp_mbs,1)} in area {%item(@cp_area,1)};}
_________________
EDIT: I didn't like my old signature
Reply with quote
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Mon Nov 16, 2009 5:59 am   
 
Sorry to puzzle you with that code.

The campaign consists in 10-15 mobs to kill, a list given by the cp master. This list i want to store in the cp child window and then i want to change the colour of each mob killed from white to red (i don't suppose you can remove the line containing a certain variable, can you?)
After the %additem thingy i'll use the subregex Charneus helped me with earlier and then i'll do a mapquery. I'll see if i can get the code working, i might need some more help.

Thank you for the #window info! I'll test it tonight.
Reply with quote
kroz
Beginner


Joined: 13 Oct 2009
Posts: 10
Location: Bucharest, Romania

PostPosted: Fri Nov 27, 2009 8:06 am   
 
I've decided to go for a combo of subregex and subchar in the end to remove all unwanted chars from my field
Code:
 @cp_mbs = %additem(%subregex(%subchar(lower(%1),"-', ",""), "^(?:the|an|a?) ")

It looks complicated but it should remove all the "the|an|a|'|-|, from my %1.. or so i hope. I've decided to drop the window issue for now since it will add lag to my zmud.
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