Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Aug 03, 2019 1:36 pm   

creating a capture for missing letters and storing those into a variable!
 
So the basics of this trigger i need is to look for a "-" inside a sentence, or paragraph and use a status window to show me the word.

example:


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

Divin- around Zombie, the t-rrifying d-ath's hea- growls deeply.

The skull di-es q-ickly towards Zomb-e but narrowl- misses.

With iron will, you finally guide the deadly spell toward its target!

explanation:

The letters that are replaced with dashes/hyphens are the letters i need to cast the spell.
The dashes/hyphens are 100% random where they appear in these phrases.
The first 2 words in each phrases is constant, so there is a way to always look for the first 2 words and find the dashes/hyphens after those words...

method:

You call forth a word of great power, would be the first stage of the spell to trigger from then look for the next 6 lines to see if there is a "-" and capture around that up to say 20 characters to be sure.

Diving around Zombie, would be the second stage of the spell and would need to look again for next 2 lines for a "-", also the name of the monster will change so there would need to be a (*) in place for the name as it could be more than 1 word, or forumlate a way to check for multiple names before the ","

The skill dives would be the third stage of the spell and again would need to look for "-"

With iron will, you finally guide the deadly spell toward its target! is the end of the spell and can be used to clear the status window and any variables that were used to capture the words in all 3 stages...

im thinking a variable for each stage; ie: #va stage1 from first phrase, etc etc...And then use the last sentence the completed spell to clear stage1 stage2 stage 3 variables for the next cast of the spell.


Thanks to all of you in advance for any help with this! i appreciate it!
Reply with quote
shalimar
GURU


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

PostPosted: Sat Aug 03, 2019 4:18 pm   
 
testing against know value is rather easy
Code:
#LOCAL $replacedLetters
$knownValue="You call forth a word of great power, invoking the prime nature of your"
$testing="You call -orth a word of great power, invoking the prime nature -f your"
#WHILE !%match( $knownValue, $testing) {
  $pos=%pos( -, $testing)
  $ins=%left( %right( $knownValue, ($pos-1)), 1)
  $testing=%insert( $ins, %remove( "-", $testing), $pos)
  $replacedLetters=%concat($replacedLetters, $ins)
  }
#SAY $replacedLetters
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Aug 03, 2019 7:41 pm   
 
touche, it can be easy.;]

however that's but one part of the larger problem...
finding the letters in a random sentence with the "-" is beyoind my abilities... much less how to extrapolate them and then store them to use later...

thank you much shalimar (again) for that portion, perhaps you could help me test out a way to make a script for the above example(s) and make permanent variables that will store the missing portions needed for any sentence with "-"?
the main problem im having is the best way to ask for the help i need, as im not certain i want a looping (within lines etc) hunting for a "-" as it likes to force a loop and crash cud:\
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Aug 03, 2019 8:17 pm   
 
You call fo-th a word of great power, invoking the prime nat-re of your
These should be the hyphenated words:

magic. Crumbling away from the corpse, the soul of the creatur- is
These should be the hyphenated words:

released in the form of a gian- death's head that flies freely into the
room, leaving behind it a great trail of radiant energy!


so i DO get the portion you posted earlier on a similar thread with me trying to find a workaround on hyphens.

#local $list
#FORALL %word(%line) {#IF (%match(%i, "-")) {#ADDITEM $list %i}}
#PRINT {These should be the hyphenated words:}
#PRINT %expandlist($list, %cr)

however it doesnt actually print the $list capture..:\ not sur ewhy
Reply with quote
shalimar
GURU


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

PostPosted: Mon Aug 05, 2019 2:04 pm   
 
Well you said the first two words are always unbroken, that makes this very easy:

First we make a new event to make this easier for us:

Code:
#EVENT onDashyLine($testing, $knownValue) {
#WHILE !%match( $knownValue, $testing) {
  $pos=%pos( -, $testing)
  $ins=%left( %right( $knownValue, ($pos-1)), 1)
  $testing=%insert( $ins, %remove( "-", $testing), $pos)
  replacedLetters=%concat(@replacedLetters, $ins)
  }}


Then we make a full on state based trigger:

Code:
#TR {You call} {
  replacedLetters=""
  #RAISE onDashyLine %trim(%line) "You call forth a word of great power, invoking the prime nature of your"
}
#COND {magic. Crumbling} {#RAISE onDashyLine %trim(%line) "magic. Crumbling away from the corpse, the soul of the creature is"} {within|param=1}
#COND {released in} {#RAISE onDashyLine %trim(%line) "released in the form of a giant death's head that flies freely into the"} {within|param=1}
#COND {room, leaving} {#RAISE onDashyLine %trim(%line) "room, leaving behind it a great trail of radiant energy!"} {within|param=1}


Then all the letters for that one spell can be accessed later as @replacedLetters, just make sure to clear it for the next spell, as this one does.

For the other question, you would need: #FORALL %replace(%line, " ", "|") {do stuff}
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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