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: Tue Jan 23, 2018 5:23 am   

extracting intergers and keeping them with missing letters
 
I am looking for help with trying to capture any lines that have this in them, doesn't matter the actual word, just need the words with the hyphens in them.
The problem I'm having is that the sentences never start with the same word/letter combination so i need something that can find the words in ANY sentence structure.

The -hostly skull r-ces around the ro-m, circling Zom-ie menacingly.

You call fort- a word of great power, invoking the prime nature of your
magic. Crumbling aw-y from the corpse, the soul of th- creature is
released in the form of a giant death's head that flies freely i-to the
room, leaving behin- it a great trail of radiant energy!

Seet-ing with venomous ang-r, th- death's head howls a- Zombi-.


Could someone please help me out here? thanks much!!
Reply with quote
shalimar
GURU


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

PostPosted: Tue Jan 23, 2018 7:52 am   
 
#TR {([%w-])} {dostuff with %1}

Make sure the 'repeat within line' option is checked down on the bottom option panel.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Tue Jan 23, 2018 8:40 am   
 
yeah way too broad a grabber, many infinite loops, the problem is the spell im using does have an achoring sentence to start it but those hyphens interrupt any kind of capturing at random, so i need a way to to do that.


You call fort- a word of great power, invoking the prime nature of your <--- You call forth a word of great power can be used to anchor, yet how do i work in the capture to allow for hyphens?
magic. Crumbling aw-y from the corpse, the soul of th- creature is
released in the form of a giant death's head that flies freely i-to the
room, leaving behin- it a great trail of radiant energy!



The ghostly apparition then dissipates away.
Reply with quote
shalimar
GURU


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

PostPosted: Tue Jan 23, 2018 8:43 am   
 
#TR {[You-] [call-] [forth-] [a-] [word-] [of-] [etc-]}
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Jan 27, 2018 5:19 am   
 
This does work for those words, however i need to find a way to use that start of the spell and ANY and all words with hyphens after it, i've tried [%w-] and it loops infinitly tons of different things, is there another way to do this?

I've use a #cond for the anchor trigger #TR {[You-] [call-] [forth-] [a-] [word-] [of-] [etc-]} to look within 5 lines to find them, and it doesn't fire work for [%w-], or ([%w]) or ([*-]). Any ideas?
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jan 27, 2018 5:44 am   
 
([%w-]) will fire on both words with and without a hyphen, this is actually expected behavior and not an infinite loop.
You have to further error test to make sure all conditions are met

#IF (%match(%1, "-")) {do something with the hyphenated word}

Perhaps if you could explain what will be done with a given word once it is found, I could help better.
_________________
Discord: Shalimarwildcat

Last edited by shalimar on Sat Jan 27, 2018 5:49 am; edited 1 time in total
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Jan 27, 2018 5:46 am   
 
hrrrm okie, so i'll put that in the #cond to match the random parts of the next lines as the first portion is the only stable words known, the rest are all random with a random hyphen in them.
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jan 27, 2018 5:51 am   
 
What will you be doing upon successfully finding a word?
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Jan 27, 2018 8:16 am   
 
well i need it to just show me what word has the hyphen then i can begin to build the remainder of the script, however that also didnt work with capturing anything, perhaps you could show me how to make the trigger with one of the examples of the output i showed earlier?
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jan 27, 2018 9:35 am   
 
#TR {[You-] [call-] [forth-] [a-] [word-] [of-]}
#COND {([%w-])} {#IF (%match(%1, "-")) {#SAY {Testing to make sure this is a hyphenated word: %1}}}

Make sure the condition or second trigger state is of Type: Loop Lines
With its value set to 5 (per your earlier instructions)
And the repeat within line checkbox checked (to make sure it checks every possible word)
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Tue Feb 06, 2018 3:55 am   
 
it works some times, but still causes fatal loops, and cmud crashes.
Reply with quote
shalimar
GURU


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

PostPosted: Thu Feb 08, 2018 6:06 am   
 
Well maybe i am overthinking the condition

Code:
#TR {[You-] [call-] [forth-] [a-] [word-] [of-]}
#COND {-} {
  #STATE 1
  #LOCAL $list
  #FORALL %word(%line) {#IF (%match(%i, "-")) {#ADDITEM $list %i}}
  #PRINT {These should be the hyphenated words:}
  #PRINT %expandlist($list, %cr)
  } {Within|Param=1}



The use of #PRINT over #SAY or #ECHO is to prevent an infinite loop.
#PRINT does not fire triggers.
_________________
Discord: Shalimarwildcat

Last edited by shalimar on Thu Feb 08, 2018 11:36 pm; edited 1 time in total
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Thu Feb 08, 2018 8:14 pm   
 
sorry man, but it said : error parsing commands, expression expected. It would not input on command line
Reply with quote
shalimar
GURU


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

PostPosted: Thu Feb 08, 2018 11:37 pm   
 
Apparently, the lack of code tags was inserting unneeded spaces.... try it now?
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Aug 03, 2019 3:10 pm   
 
#TR {[You-] [call-] [forth-] [a-] [word-] [of-]}
#COND {([%w-])} {#IF (%match(%1, "-")) {#SAY {Testing to make sure this is a hyphenated word: %1}}}


sooo it does see the hyphen in the phrase, however how do i gather the words around the hyphen?

edit:

apparently you had already shown how to expand and capture the word itself, which DID work, my apologies!


so it worked with a local variable in place as your script provided, however i need a way to make it a non-local variable, and i tried replacing

#local $list with #va list 0 just to fill the variable @list until the script provided filled it, and also changed all the local ($list) to @list so it would know to check that type of variable, and it didnt capture at all...

not too sure why there, so if you or someone else could explain that i would appreciate it! thanks.
Reply with quote
shalimar
GURU


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

PostPosted: Mon Aug 05, 2019 7:28 pm   
 
it would be: #ADDITEM list "value"
not: #ADDITEM @list "value"

it is likely trying to expand @list in the wrong place, thereby defining an odd variable
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Mon Aug 05, 2019 8:26 pm   
 
That fixed it! thanks again shalimar:P
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