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
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Tue Jan 13, 2015 9:39 am   

Create a trigger/alias help
 
HI everyone, i just wanted to say thanks ahead of time for any and all help! This forum has always been super helpful!!!!

In a nut shell, There is a power my mud(guild) uses and it's quite a pain in the butt due to combat scrolling and being able to decipher missing words in a set phrase(phrases) and "speak" them in line after the phrase has been sent. I was hoping to capture the text sent, and form a way (alias or macro etc) to send back the missing parts of the phrase fast enough to actually use the spell...

now.... the captured text is randomish in word's however there is ALWAYS a set phrase when invoking the power and always ONLY 3 lines or phrases sent after the intial start of the power, i'm hoping someone would know a way to make somethng workable out of this information. also there is only a "-" for the missing letters in the phrase. Also, in the last phrase the second to last word is random based on the nature of the spell.
(IE: rdiant, smoking, etc etc but always a word)

to send the necessary information (missing letters back tot he mud i input, invoke prime missing letters... IE: invoke prime aeft.


here are a few examples of what is sent from the mud.

You call -orth a word of great power, invoking the prime nature of your
magic. Crumbling away from th- corpse, the soul -f the creature is
released in the form of a giant death's head that -lies freely into the
room, leaving behind it a great trail of radiant energy!

Screaming -hrough the r-om, the death's h-ad growls at Griffin.

With a hor-id grin of d-ath, the gh-stly skull leers at Griffin.


You call forth a word of great -ower, invoking the prime nature of yo-r
magic. Crumbling away from the corpse, the soul of the creature is
released in the f-rm of a giant death's head that flies freely into the
-oom, leaving behind it a great trail of smoking flames!

The ghost-y skull bobs and weav-s around A Ramen C-rd Band, growling fiercely.

The skul- dives quickly t-wards A Ramen Cord B-nd but narrowly misses.


SO yeah, ANY help would be greatly appreciated thanks so much!!!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Tue Jan 13, 2015 1:00 pm   
 
Well, so long as you have a known answer to compare it to, it should be fairly simple.

You need to capture the block of text
concatenate it together into a single string
find the %char positions for the hyphens
then find the corresponding characters from the answer key.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Wed Jan 14, 2015 3:00 am   
 
Hmm, i understand what you mean, but honestly i'm not that familiar at all with cmud's scripting system, could you show an example please? Thanks!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Wed Jan 14, 2015 5:39 am   
 
The biggest hassel will be finding anchor points so as to capture the block of text in the first place.
Ideally you would use a command input trigger to know what to expect in advance, so that a trigger that otherwise might trigger to often, only needs to be enabled when you are expecting it to fire.
Here is a rough example for the info you provided.

#TR "deathHand" {^You call} {testString=%line}
#COND {*} {testString=%concat(@testString, %line);#IF (!%match(%line, "leaving behind it a great trail of")) {#STATE 1}}

That trigger will attempt to capture the block of test into a variable @testString.
The if statement will keep the trigger on its second state until it finds a line that matches an unchanging segment of the final line of the block.
You can add the else segment of the if statement for whatever it needs to do to manipulate your testString against the known key.

Which would be something like.....

thisAnswer=""
#LOOP %len(@testString) {#IF (%pos(@testString, %i)="-") {thisAnswer=%concat(@thisAnswer, %pos(@answerKey, %i))}}

Which sets the answer to null, then tests each character of your string for hyphens, this retrieves the correct character from the same possition of the answer key, then adds it to the new answer

To find out what the various commands and functions i am using to you can use the following syntax:
#HELP #IF
#HELP %pos
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Wed Jan 14, 2015 6:42 am   
 
{#IF (%pos(@testString, %i)="-") i understand this part.. at any position of the variable @teststring , the second part of the #IF will concate the answer of that variable and send it.... however %len means to count them? why does it need to count them, forgive me for being extremly dense.... but i'm just not used to this at all. And again thanks so much for helping me, i truly appreciate it!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Wed Jan 14, 2015 6:52 am   
 
its counting the total length of the string so it knows how many iterations of the loop to perform
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Wed Jan 14, 2015 7:24 am   
 
Aweomse, i see how that works now! Ok there is one hang up with the intial trigger(anchor point), I have several powers that use You call in the start of their use, so it is looping endlessly and causing crashes. Could i use a {Skip|Param 10} or some amount as there are only 4-5 lines after the initial cast. Also as a further point to find the next 2 anchor points, is it possible to allow the multi-state to look for the next hypenated lines and concate the information it sees? Sorry to keep bugging, just trying to finish this.
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Wed Jan 14, 2015 7:28 am   
 
Ugh, i see how you made the #cond work, it stops looking if it sees the end of the first phrase, however if it doesnt see that it continues to loop, so yeah that's the only issue i see thus far.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Wed Jan 14, 2015 9:57 am   
 
its not a perfect solution, it depends on just how random everything is..... if there is no constant whatsover you may need a more complicates pattern
i was just thinking of an alternative, using the range paramater of patterns....



#TR {[You-] [call-] [forth-] [a-] [word-] [of-] [great-] [power-], [invoking-] [the-] [prime-] [nature-] [of-] [your-]} {
key=You call forth a word of great power, invoking the prime nature of your
then the loop to check each line as we go
}
#COND {a similar pattern for the second line} {}
#COND {and the third} {}
#COND {and so on} {with all your script cleanup at the end}
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Thu Jan 15, 2015 4:50 am   
 
Hmm, inside the phrase there is no real anchor point no:( ... So im guessing its based on capturing or finding hypens in sentences after the 1st phrase which ALWAYS says the same thing, but also always has random hyphens throughout it..:(
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Thu Jan 15, 2015 9:14 am   
 
the range wildcards i am using [You-] means that only those characters listed inside the square brackets are allowed to be part of the string in question.
It takes a little longer to set up, but it should work.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Apr 04, 2015 12:00 am   
 
I've been thinking about this some, well it seems i'd need first a way to fill the missing letters AFTER the script recognized where they are missing. regardless of the fact i've yet to get any script to do that. BUT when i do, i think i'd have to make a function of some sort to take th- and show the, and therefore the missing letter is filled...
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Apr 04, 2015 4:16 am   
 
I think Shalimar is on the right track with the range patterns, but a critical detail is missing. You will need a regex instead of zScript pattern. The reason for using a regex is to repeat the symbol range the correct number of times.
Code:

#REGEX {[You-]{3} [cal-]{4} [forth-]{5} [a-] [word-]{4} [of-]{2} [great-]{5} [power-]{5}, [invokg-]{8} [the-]{3} [prime-]{5} [nature-]{6} [of-]{2} [your-]{4}$} {
InvokeReport=""
$str="You call forth a word of great power, invoking the prime nature of your"
$cap=%line
$pos=%pos("-".$cap)
#WHILE ($pos) {
 InvokeReport=%concat(@InvokeReport,%copy($str,$pos,1)
 $cap=%right($cap,($pos+1))
 $pos=%pos("-",$cap)
}
}
You would then add conditions for the following lines with the nearly the same code. Obviously you don't clear the variable on the sub-states, must set the patterns correctly, have to change the value of $str, and the last one would send the command. You should set the case-sensitive flag on all the triggers, and make sure the regex flag is set for all the sub-states or the will fail.
_________________
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