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
cachew
Novice


Joined: 10 May 2001
Posts: 39
Location: USA

PostPosted: Tue Aug 21, 2007 5:32 am   

2 Questions Prompts & A Substitution
 
Question #1 - When grouped the dynamic inclusion of the leading <[82%]Enoka> causes a problem with the variables updating properly.

2 Prompts, the first is my normal non-grouped prompt. The second is a grouped prompt where someone is taking damage in the group. The grouped prompt is dynamic and the <[82%]Enoka> portion of the prompt appears only when a group member takes damage. If the person in the group is healed to full the <[82%]Enoka> portion will disappear.

<537hp 835m 560mv 100br>
<[82%]Enoka><537hp 835m 560mv 100br>

2 working prompts that I have:

Code:
<(&HP)hp (&MP)m (&Move)mv (&Breath)br>

Code:
<~[(&PartyMemberHealth)~%~](&PartyMember)><(&HP)hp (&MP)m (&Move)mv (&Breath)br>


The normal prompt works fine when not grouped. When grouped the HP variable has stored into it the <[82%]Enoka> value as opposed to the numeric value of the HP. Anyone have an idea how to fix this?

Question #2 - I am looking to parse and then substitue the following text.

This is the orginal text:

Marious, the Great Wizard looks at a magic orb placed here by Vryce....
Marious, the Great Wizard telepaths you, 'Let's see here... I see an entrance at...'.
Marious, the Great Wizard telepaths you, 'An Uneven Rock Passageway'.
Marious, the Great Wizard telepaths you, 'in the general vicinity of'.
Marious, the Great Wizard telepaths you, 'Warrens of the Moshata'.
Marious, the Great Wizard telepaths you, 'The entrance has just been uncovered.'.

I would like a substitution that reads as the following:

Let's see here... I see an entrance at An Uneven Rock Passageway in the general vicinity of Warrens of the Moshata. The entrance has just been uncovered.

I have tried a looplines trigger and I can get some of the lines into variables but they arent going in the proper variables. I have tried to write out the text to file then read in the info from there and a host of other things that turned out equally poor. Anyone have an idea how to code this?

Any help would be appreciated, my mediocre programing skills are coming into clear view.
_________________
Christopher Chew
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Aug 21, 2007 9:17 am   
 
A1:Use one regex trigger.

(?:<[(\d+)\%](\w+)>)?<(\d+)hp (\d+)m (\d+)mv (\d+)br>

There's a reference for regex syntax here, but in short, the (?:stuff) part causes that part not to be put into the %nn variables and the ? after that part makes the whole lot in brackets optional.

The problem with this is going to be that you can't use named arguments in a regex trigger in zMUD and when the first part of the regex matches, it'll bump the hp etc values up two places from %1 to %3. You could do something like

#if (%2=~"%a") {}

to see if %2 contains letters instead of numbers.

A2:You don't need to use a file; you already have variables for storing stuff. How about something like this?

#trig {Marious, the Great Wizard looks at a magic orb placed here by Vryce} {StoredTele=""}
#cond {Marious, the Great Wizard telepaths you, '(*)'} {StoredTele=%concat(@StoredTele," ",%1)} {looplines|param=5}

I haven't used looplines in a while, but I think that's right.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Tue Aug 21, 2007 1:44 pm   
 
Fang Xianfu wrote:
A1:Use one regex trigger.

(?:<[(\d+)\%](\w+)>)?<(\d+)hp (\d+)m (\d+)mv (\d+)br>

The problem with this is going to be that you can't use named arguments in a regex trigger in zMUD and when the first part of the regex matches, it'll bump the hp etc values up two places from %1 to %3. You could do something like

#if (%2=~"%a") {}

to see if %2 contains letters instead of numbers.

Actually, that's not a problem. The assignment of groups to their index numbers is independent of whether or not a group matches. You simply count open parens in the pattern, ignoring those that start with ?. So, the %# syntax is never dependent on what the input text is... well, unless it happens that the match can happen differently, that is--but that's a question about what the matching text for a group is, not which group it is.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Aug 21, 2007 3:56 pm   
 
I stand corrected. If the optional part at the start matches, %1 and %2 will have values, otherwise they'll be null. %3 will always be the hp, and so on.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
cachew
Novice


Joined: 10 May 2001
Posts: 39
Location: USA

PostPosted: Tue Aug 21, 2007 4:36 pm   
 
Is there any way that this could be done with named variables? I wrote these triggers when I first started playing medievia years ago and the variable names are used in numerous triggers all over the place.

I would assume this has been done before. Considering that this is the default Med prompt and with the sheer number of players and the necessity of the issue I would would not want to reinvent the wheel if it can be helped. =)
_________________
Christopher Chew

Last edited by cachew on Tue Aug 21, 2007 4:41 pm; edited 1 time in total
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Tue Aug 21, 2007 4:39 pm   
 
Just do the variable assignment in the trigger: #VAR PartyMemberHealth {%1} etc
Reply with quote
cachew
Novice


Joined: 10 May 2001
Posts: 39
Location: USA

PostPosted: Wed Aug 22, 2007 9:04 am   
 
thanks again gentlemen, as always, very helpful.
_________________
Christopher Chew
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Aug 22, 2007 9:44 am   
 
To answer your second question you have to use a multistate trigger and some logic.
Code:
#CLASS MariousHandler
#VAR Marious {} {}
#TRIGGER "MariousCap" {^Marious, the Great Wizard looks at a magic orb placed here by Vryce....$} {Marious="";#GAG}
#COND {^Marious, the Great Wizard telepaths you, '(*)'.$} {#GAG;Marious=%concat(@Marious,"%1"," ");#IF (%ends("%1",".")) {#IF (%ends("%1","...")) {#NOOP} {#STATE MariousCap 0;#SAY {@Marious}}}} {looppat|param=10}
#CLASS 0
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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