 |
holyflame77 Newbie
Joined: 23 Nov 2008 Posts: 6 Location: NC
|
Posted: Sun Nov 23, 2008 8:40 pm
Capturing lines of text to Var |
I am trying to make a script to automatically capture lines of text from my game and input it into the Mappers Notes section, the part I am having trouble with is getting it to capture the lines into the variable. I've looked through the Help files to find a solution, but nothing I can find is what I need, though I'm sure there is a way. I know you could do it with zMUD, but I can't remember how. Here is a basic idea of what the opening Text is for Shops:
Item/Price
An oil-soaked torch, a small wood light, for 1 silver, 5 copper.
A fried zakami breast, a small meat foods, for 7 copper.
A fried zakami leg, a small meat foods, for 6 copper.
Some fried zakami nuggets, a small meat foods, for 4 copper.
A small, drinking flask, a small leather drink container, for 1 silver, 5 copper.
A small canteen, a small leather drink container, for 1 silver, 5 copper.
Item/Price is what you'll use for the trigger itself, but what command do you use to capture the text to a variable? I tried #Capture, but it just puts it into the Editor. Each shop will have a varying number of items, so is there a way to make it know how many lines there are? Or should I just use a set 20 lines or something? The same applies to trainers, here is a sample of that.
A wrinkly male gnome will teach the following:
Wands for 1 silver, 5 copper
Ventriloquate for 1 silver, 5 copper
Magic missile for 1 silver, 5 copper
Invis for 9 silver
Fly for 9 silver
Detect invis for 9 silver
Detect hidden for 9 silver
Color spray for 9 silver
Again, I can make the triggers, but capturing the text...thats what I can't figure out...Thanks in advance.
Holy Flame. |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Nov 24, 2008 1:51 pm |
One common way to do this is to have the first trigger turn on another trigger which does the capturing. This would be a trigger on "*", so it triggers on every line. The problem, as you have realized, is letting the triggers know how many lines to capture. If there is a variable number of lines, the only good way is to create another trigger for the line which /follows/ the text you want to grab, and turns off the capturing trigger. You don't show us what lines come after the text you want, so I can't give you anything specific. If there is a standard line at the end, that would be perfect. Otherwise, you may have to trigger it on the prompt or something like that.
|
|
|
 |
holyflame77 Newbie
Joined: 23 Nov 2008 Posts: 6 Location: NC
|
Posted: Mon Nov 24, 2008 10:29 pm |
The end is only signified by a blank line...is it possible to trigger of just a blank line itself? I know there is a wildcard for that...*ponders* I'll try it and see...something else...I did manage to make a trigger that would capture the training text... $(%w) (for) (*) with an var test = {%1 %2 %3}....however, it took a lot of reading and trials to get it working right, but after I got it ALMOST working perfectly, it decided it didn't want to work anymore....not sure if its just cMUD acting up or what...cause I have the same thing that worked before, that won't work now....*sighs* Almost seems as if cMUD decided to say, I'm tired of all this trial and error, leave me alone.. ;) Anyway, any help would be appreciated, will try your suggestiogn. Will post whether or not it works... :D
Holy Flame. |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Nov 25, 2008 3:16 am |
^$ will match a blank line.
If you have code, let us see it and we can help you troubleshoot it. |
|
|
 |
holyflame77 Newbie
Joined: 23 Nov 2008 Posts: 6 Location: NC
|
Posted: Wed Nov 26, 2008 12:30 am |
Ok, here is a rough idea of what I have....
Pattern: (*) will teach the following~:
#T+ TrainList <--to turn on the trigger that will capture text
#CALL %roomcol(,yellow) <--to color current room in mapper to signify has a trainer
Pattern: (*)
#ADDITEM Rm(%roomnum(,)) %1 <--Ok here, I did have a normal variable (RmTrainList) but I noticed that while it put the info into the room notes, after leaving the room, it erased it...thought maybe cause its set to the var RmTrainList so I tried to make a new Stringlist for each room, starting with Rm(roomnum) but it doesn't seem to work....so I'm halfway there, I got it to do what I want, but I can't seem to get it to stay in the notes...
Pattern: $
#T- TrainList
#CALL %roomnote(,@Rm(%roomnum(,)))
Keep in mind this is what I came up with recently....the original just had RmTrainList as the variable, instead of the Rm(%roomnum(,) stuff... |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Nov 26, 2008 2:51 pm |
Your current code will be making lots of those variables, and you don't seem to be deleting them after you put the data into %roomnotes. When you used @RmTrainList, did you have something to delete the variable or the contents of the variable? If so, that is probably why you saw it delete the data in %roomnotes. Your last trigger should have a pattern of "^$", not "$". As it is, you are copying the data to %roomnotes after every line, not just blank lines. Also, I don't think your attempt at concatenation to create a variable name will work well. And you probably want to turn off the third trigger as well as the second trigger. So, here is my suggestion (not tested):
Code: |
#TRIGGER TrainListStart {(*) will teach the following~:} {#T+ TrainList;#T+ TrainListEnd;#CALL %roomcol(,yellow)}
#TRIGGER TrainList {(*)} {#ADDITEM RmTrainList %1} disable
#TRIGGER TrainListEnd {^$} {#T- TrainList;#T- TrainListEnd;#CALL %roomnote(,@RmTrainList)} disable
|
|
|
|
 |
|
|
|
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
|
|