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
hjanfield
Newbie


Joined: 23 Oct 2007
Posts: 5

PostPosted: Sat Oct 16, 2010 1:38 am   

Trade Wars 2002 - having trouble
 
I'm having a problem with a trigger that has a repeating section in zMud.

I'm trying to make a handful of triggers to help me out in Trade Wars 2002. I'm not trying to recreate the major functionality of the many "trade wars helper" programs out there, I do not want to have a program that plays the game for me. I just want a few things to work.

Anyway, the trigger I am having trouble with is this:

Code:
^Warps to Sector\(s\) :  \(?(\d+)\)?(?: - \(?(\d+)\)?)*


The line to match looks like:
Code:
Warps to Sector(s) :  (424) - 308 - 2479 - (5543) - (69)

This line could have anywhere from one number to 10 numbers (I think no more than ten?), with or without brackets around the number.

For some reason, it will only return the *last* match of the repeating section. So on this sample line, I would end up with %1 = 424 and %2 = 69. 308, 2479, 5543 would be lost.

The only way I can get this trigger to work properly is as such:
Code:
^Warps to Sector\(s\) :  \(?(\d+)\)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?(?: - \(?(\d+)\)?)?
which is a bit stupid ;)

Is there any better way? Do I need to create a revolving trigger which matches first on the initial text (without Newline), then keeps matching individual numbers until a newline is reached? Seems dumb...
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Oct 16, 2010 5:48 pm   
 
#trigger {^Warps to Sector~(s~) : ([~(%d%s-~)])$} {
...stuff you want to do...
}
_________________
EDIT: I didn't like my old signature
Reply with quote
hjanfield
Newbie


Joined: 23 Oct 2007
Posts: 5

PostPosted: Thu Oct 21, 2010 12:41 am   
 
Bleargh, non-regex triggers!? Are you daft? ;)

Anyway, this still doesn't do what I want. Using the sample line in the first post, that trigger gives me a result of:
%1: (424) - 308 - 2479 - (5543) - (69)

What is desired is:
%1: 424
%2: 308
%3: 2479
%4: 5543
%5: 69

I just can't figure out why my original pattern only matches first and last, and not the ones in between.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Oct 21, 2010 9:49 pm   
 
They don't get captured in separate variables but it is trivial to make them so because from the look of it the numbers are always interspersed with a dash so you can just replace the dash with a pipe and then you have a string list you can iterate through.
_________________
Taz :)
Reply with quote
hjanfield
Newbie


Joined: 23 Oct 2007
Posts: 5

PostPosted: Fri Oct 22, 2010 1:58 am   
 
Hmm.
Wish I could get zMud to understand PHP, then I'd have no trouble doing anything! :)

I'll give that a try.

Meanwhile, I'm having trouble getting the mapper to cooperate with me.
I can tag one line as a room name, a number from it as a vnum, but it won't recognize it. Of course it won't recognize exits, since I need to code all that manually for the weirdness of it, but why won't it recognize a "room" when I tell it to?

Also, when adding exits via script, how can I force a link direction? In the mapper, I can manually set an exit of "60" with an exit direction of E for visual reference and then go to that room 60 and set an exit "123" to the W to return the link... but I can't find a way to do this via script.

My long-term goal is to make a simple mapper for TW2002. Doesn't need to be fancy; just needs to collect:
Sector: 123 in Some Area. // capture "Sector 123" as room name and 123 as vnum)
Warps to Sector(s): as shown above, with each number being an exit linking to a room of the same #.
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