|
yipfur Beginner
Joined: 12 Jan 2003 Posts: 13 Location: Australia
|
Posted: Sat Sep 15, 2012 7:27 am
captureing lines after a trigger line |
Hi
I am useing cmud. I am trying to capture multipul lines after a line I can use as the trigger upto another line that I can use as the ending trigger. The output from the mud is.
You know the following defensive magic spells:
Endorphin's Floating Friend Transcendent Pneumatic Alleviator
You know the following offensive magic spells:
Kamikaze Oryctolagus Flammula Narquin's Mist of Doom
Nargl'frob's Empyrean Spear Pragi's Fiery Gaze
You know the following misc magic spells:
Collatrap's Instant Pickling Stick Jogloran's Portal of Cheaper Travel
Floron's Fabulous Mirror Master Woddeley's Luminescent Companion
I would like to have the line You know the following defensive magic spells: as the starting trigger and capture all the words upto You know the following offensive magic spells I would be putting the words Endorphin's Floating Friend Transcendent Pneumatic Alleviator into a variable and from there I would like to put them into a database. I would like to be able to repeat the process on the other sections so I can collect the infomation between offensive spells and misc spellsl. I would be collecting the information Kamikaze Oryctolagus Flammula Narquin's Mist of Doom Nargl'frob's Empyrean Spear Pragi's Fiery Gaze which in over several lines and do the same for the misc spells.
The information changes depending on what spells I have.
I have spent some time on trying to figure out how to get this information and have tryed things like cond command makeing string lists and other ways. My problem is I can't work out how to get the lines that follow a tigger line into a variable which I hope I can then phase to put into a database and build up infomation on all my spells so I can be informed about them. I can then gather further infomaiton from other trigger lines but for now I am stuck on getting the lines that follow in the above starting example.
Please advise on the commands and format to do this
Thank you
Yipfur[/i] |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sat Sep 15, 2012 1:49 pm |
You will need one more piece of information--the text which indicates the end of the misc spell list. I assume that will be your prompt. For the following code, I will assume that your prompt is ">"; change that if your prompt is different. Cut and paste the following into the command line:
Code: |
#TRIGGER "spellcatch" {You know the following defensive magic spells:} {#VAR defspells {}; #VAR offspells {}; #VAR miscspells {}}
#COND "spellcatch" {(*)} {#IF (%trim(%1) == "") {#EXIT}; #IF (%begins(%1, "You know the following offensive magic spells:")) {#STATE spellcatch 2} {#ADDITEM defspells %1}} {manual}
#COND "spellcatch" {(*)} {#IF (%trim(%1) == "") {#EXIT}; #IF (%begins(%1, "You know the following misc magic spells:")) {#STATE spellcatch 3} {#ADDITEM offspells %1}} {manual}
#COND "spellcatch" {(*)} {#IF (%trim(%1) == "") {#EXIT}; #IF (%begins(%1, "> ")) {#STATE spellcatch 0} {#ADDITEM miscspells %1}} {manual}
|
|
|
|
|
yipfur Beginner
Joined: 12 Jan 2003 Posts: 13 Location: Australia
|
Posted: Mon Sep 17, 2012 12:32 pm |
Thank you Rahab, It is getting the info into a variable. You are right in me not supplying the ending trigger. It is > so at the moment it is putting in the misc spells again and again as I run it do yo have a fix for this as I am a little lost at what you have done. I tryed to do a similar thing to what you did but it keep creating the same trigger again and again. So although on the right track I was miles off.
When the spell is put into the varialble it is done like this;
Endorphin's Floating Friend Transcendent Pneumatic Alleviator
Do you have a way I can isolate each of this into a seperate variable and then be able to send them off to the database I want to create for them?
One variable would be Endorphin's Floating Friend
Two variable would be Transcendent Pneumatic Alleviator
I think from that point I would be able to proced. I am thinking some sort of string maniputation?
So to sum up
Misc keeps putting in the same info again and again, guessing its something to do with the prompt >
and being able to seperate each of the spells so I can put them in a database and then use other triggers in other commands to populate the database with the info I nee. I already have a start on the database.
Thank you Rajab
For you time |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Sep 17, 2012 1:10 pm |
As Rahab said, you need to change the ">" bit if your prompt is different. For example, if your prompt is [###/###hp ###/###mana], you would put "~[%d/%dhp %d/%dmana~]" there. If you need help writing a pattern for your prompt, you'll need to post it.
As for splitting the spells, that'll be trickier. Since there's no separator between them that you can split on, you'll need a list of all the spells, then you can check which ones are in the string. Here's a simple loop you can use:
Code: |
$spell = ""
#LOOP %numwords(%1) {
$spell = %trim(%concat($spell, " ", %word(%1, %i)))
#IF %ismember($spell, @allmiscspells) {
#ADDITEM miscspells $spell
$spell = ""
}
}
|
This whole block would replace the #ADDITEMs in each of the three trigger states in Rahab's code. Make sure you adjust the variables for each one. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Sep 18, 2012 12:56 pm |
Yipfur, I'm not sure what you mean. My code should be entering the spells of each category into a stringlist.
You can access each entry in a stringlist separately, with either the %item() function, or the @variable.1, @variable.2
syntax. You don't need to put each spell into a separate variable. You haven't explained how you want to send this
data off to a database, so I haven't given you any code to do that. If you explain what you want with that,
we can help. But I'm not even sure you need a separate database for them. The stringlists may be sufficient.
Can you explain exactly how you want to access the spells or spell lists? |
|
|
|
yipfur Beginner
Joined: 12 Jan 2003 Posts: 13 Location: Australia
|
Posted: Mon Sep 24, 2012 5:33 am |
Hi Rahab the code you gave me works to a point, I was hopeing to be able to get each complete spell on its own so I can put it into a database. From your replay I feel you might think what you have done for me is not helping, if fact it has put me on the right track and I apprciate your help. I have manualy put all the spells into a data base now it took some time as there was a lot of information and a lot of spells, I am now using the database I have made to supply me with information using show to let me know information about the spell. I have also developed triggers that are filling in other bits off informtion into the recored of a parcitulaer spell. It is somewhat working.
How ever I can still not get the spells to be on there own. Idealy Endorphin's Floating Friend would be alone and then the next spell in the list Transcendent Pneumatic Alleviator would be on its own. The output in the mud is Endorphin's ''Floating Friend Transcendent Pneumatic Alleviator'' there is a big space of blank spaces between each spell and I have been trying to work out how to seperate the spells on the long line of spaces. I have read a lot of help files on string manipulatin and can not work it out so I am once again turning to the formus for help. thank you |
|
|
|
yipfur Beginner
Joined: 12 Jan 2003 Posts: 13 Location: Australia
|
Posted: Mon Sep 24, 2012 5:36 am |
Hi pretented that a dot . is a space the output looks like this;
Endorphin's Floating Friend ....................................Transcendent Pneumatic Alleviator
So the output of the mud is a big space, wouldn't I be able to split each the spells on there own along that space.
cheers
yipfur |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Sep 24, 2012 12:23 pm |
If each spot for spell names is the same length, you can use the &nnn fixed-width wildcard. You would need to %trim() the trailing spaces.
A regex pattern might more directly match it, though. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Sep 24, 2012 1:14 pm |
Ah, I hadn't realized that when I wrote my code to split them. Could you post a few more lines of that, in a [code] block? That'll preserve the spacing.
|
|
|
|
|
|