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


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 2:38 am   

Capturing a variable inside []
 
Hey Guys, For some reason I cant seem to catcha number located inside [] and save it as a variable.

heres the game output:

Spells currently memorized:
1: [ 1]ancestral shroud [ 2]bone shape [ 2]satiate
[ 1]spectral glow [ 1]spiritual guidance
2: [ 1]ancestral blessing [ 3]blindness [ 1]cure blindness
[ 1]endurance [ 1]remove curse
3: [ 1]delay death [ 1]spectral sight [ 4]vile spirits
4: [ 1]amplify spirits [ 1]monstrous mantle [ 4]soul leech
5: [ 1]boiling blood [ 3]cure critical [ 1]ghostmaster ritual
6: [ 1]ancestral spirit [ 3]regenerate

Specificly at the moment I want to capture 3 and save it as the variable regen
here's my code:
Pattern: [%p]regemerate

#cw Gold,blink
#capture XP
#var regen %1

so what am I doing wrong? this method has served me well previosly, but I think its the [] that are messing it up.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu Oct 13, 2011 3:01 am   
 
[ and ] are characters that have a special meaning in patterns. If you want them to be interpreted literally, you need to put a tilde before them. Also, there's a couple other problems with your it. Firstly, you're not actually capturing the number - you need to put () around parts of the pattern that you want to be saved to %1, %2, etc. Secondly, %p matches punctuation characters. You want %d instead, for digits. So the final pattern would be:
Code:
~[(%d)~]regenerate
All of this is explained in the CMUD manual btw, on the page on pattern matching.
Reply with quote
Dakina
Novice


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 3:10 am   
 
Thanks Daern, Ive read through allot of the starting scripting stuff, but get the %letters mixed up. Thanks a bunch
Reply with quote
Dakina
Novice


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 3:12 am   
 
Ok, that dosnt work, and now it dosnt capture the line to another screen like before

~[(%d)~]regenerate
is the exact pattern I am using now
#cw Gold,blink
#capture XP
#capture status
#var regen %1
is the script
Reply with quote
Dakina
Novice


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 3:26 am   
 
Figured out I needed to add a space inbetween the [ and (%d and now it kinda works, however, the mud outputs:

Spells currently memorized:
1: [ 1]ancestral shroud [ 2]bone shape [ 2]satiate
[ 1]spectral glow [ 1]spiritual guidance
2: [ 1]ancestral blessing [ 3]blindness [ 1]cure blindness
[ 1]endurance [ 1]remove curse
3: [ 1]delay death [ 1]spectral sight [ 4]vile spirits
4: [ 1]amplify spirits [ 1]monstrous mantle [ 4]soul leech
5: [ 1]boiling blood [ 3]cure critical [ 1]ghostmaster ritual
6: [ 1]ancestral spirit [ 2]regenerate

Spells being memorized:
6: [ 1]regenerate


And it is capturing the 2nd instance of regenerate, not the first, which is the one I want. any thoughts?
Reply with quote
Dakina
Novice


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 3:51 am   
 
Is there any way to make the first time it shows up var regen1 and the 2nd time regen2? there will never be more than 2 times on the screen, sometimes only 1, and I can use both the variables eventually
Reply with quote
shalimar
GURU


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

PostPosted: Thu Oct 13, 2011 4:16 am   
 
Name the capture trigger or stick it into a class folder and use this:

#TR {^Spells (%w) memorized:} {
#IF (%1=currently) {#T+ triggerName}
#IF (%1=being) {#T- triggerName}
}
_________________
Discord: Shalimarwildcat
Reply with quote
Dakina
Novice


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 4:44 am   
 
Thanks Shalimar
Reply with quote
Dakina
Novice


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 4:48 am   
 
ok so I put the trigger in a class folder and added the above script to the trigger and it produced:

mem
Spells currently memorized:
1: [ 2]bone shape [ 1]satiate
2: [ 3]blindness [ 1]cure blindness [ 1]endurance
[ 1]remove curse
3: [ 1]delay death
4: [ 1]amplify spirits [ 4]soul leech
5: [ 3]cure critical [ 1]ghostmaster ritual
6: [ 1]regenerate
1 Regens left

Spells being memorized:
1: [ 1]ancestral shroud [ 1]satiate [ 1]spectral glow
[ 1]spiritual guidance
2: [ 1]ancestral blessing
3: [ 1]spectral sight [ 4]vile spirits
4: [ 1]monstrous mantle
5: [ 1]boiling blood
6: [ 1]ancestral spirit [ 2]regenerate
2 Regens left

You estimate your studies will complete in 2 (game) hours.

Spells left (level-number): 1-0 2-0 3-0 4-0 5-0 6-0 7-2

253H 125V 6639696X 4247C Mem:2 Exits:ES>
say @regen
You say '2'
Reply with quote
Dakina
Novice


Joined: 22 Apr 2011
Posts: 36
Location: Colorado

PostPosted: Thu Oct 13, 2011 4:49 am   
 
For the purpose of the Alias, which I will use for several things, one of which: gtell @regen Regen's Left, it wont work, because mem gives the mem list and the memming list at the same time, no way to seperate them
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Thu Oct 13, 2011 5:46 am   
 
Give your trigger that catches the number an id of triggerName and reread Shalimar's post. Look up the commands #T+ and #T-.
_________________
.geniusclown
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