|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sat Feb 09, 2002 4:28 am
need trig to read multi-lines & store list to #var |
I want to make (a) trigger(s) that can read multiple lines and store them in a list fasion and then store them into a variable.
The list I need the trigger to read from looks something like this (note: its random each time, and can list same item more than once).
You still need to find the following:
A spiked buckler.
An onyx ring.
Sting.
A rotten arm.
I have an alias to get all of the possible items in the format of the first letter of each word, and the last typed out.
EX: A spiked buckler.
has an alias qasbuckler
EX: Sting.
has an alias qsting
I want to make a trigger that can store each the the aliases in a variable group
so it would be like @qitems {qasbucker;qsting;ect;ect}
so when that variable is executed it runs all 4 at once.
This will be stored to a macro key with....
#key key7 {@qitem}
I just need to get triggers that can do this and I don't even know where to start.... Please help if you can. :)
RaZ |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Feb 09, 2002 6:34 am |
Lets see...hrm, looks like you have a good plan in mind. I wouldn't really recommend doing all your aliases at once, but then I don't know what you have in them so it is an empty nonreccomendation. Anyhow some small part of a setup for you:
#TR {^You still need the following~:$} {#T+ CaptureQuestList;QuestList="";#ALARM {+10} {#T- CaptureQuestList}}
#AL ParseQuestList {QItems="q";#WHILE (@QuestList!="") {#IF (%pos("|",%word(@QuestList,1) {QItems=%concat(@QItems,%item(@QuestList,1),";q");#DELNITEM QuestList 1} {#IF (%numwords(@QuestList)=1) {QItems=%concat(@QItems,@QuestList);QuestList=""} {QItems=%concat(@QItems,%left(%word(@QuestList,1),1));QuestList=%trim(%remove(%word(@QuestList,1),@QuestList)}}}}
#CLASS CaptureQuestList
#TR {^(*).$} {#ADDITEM QuestList {%1}}
#TR {^$} {#IF (@QuestList!="") {#T- CaptureQuestList;ParseQuestList;#NOOP I am assuming a blank line follows the list.}}
#CLASS 0
The biggest part of this is the parsing alias to convert it into the format you want, hopefully I don't have too many typos. I am sure you can flesh out everything else. |
|
|
|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sat Feb 09, 2002 8:54 pm |
Well...that looks like greek to me...I know a few of the zmud commands, but less than half of those, I attempted to read through the help files, but so far I've been better off to play with things and guess what they do than depend on a helpfile explination. I usually like to use things that I understand, and I don't really understand much of that.
Is there perhaps any more simple way to do it? I think I forgot to mention I already have a trigger as well as an alias to react to every possible list item. Maybe theres a way for me to integrate the #additem command into this script? And set up a new trigger for when the quest is completed to remove all of the contents of the variable? My script will already function as a full blown bot with nothing that stops it, but I want to make it work off an #key that exectutues a variable, due to the rules and regulations of different muds.
Or if it would be easier for you, you can try to teach me how yours works?
RaZ |
|
|
|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sat Feb 09, 2002 9:15 pm |
I copy pasted yours to try it, to see if I could understand it...
I checked to make sure everything was created properly, and everything was.
I then typed complete card..which is the syntax to recieve the list of Items..
It showed me the item list, and stored the list correctly the the @questlist variable..I checked it with #sh @questlist
Then I typed in parsequestlist, in the command line and pressed the enter key..All I saw was an infinite loop of #IF | scrolling in respose to everyline from the mud.. was pretty neat looking, but I don't think thats what you had in mind :P
Any suggestions at what could have went wrong?
RaZ |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Feb 09, 2002 9:28 pm |
I will see if I can explain what I am doing here. Although you say you already have triggers for all of it so I don't see why you asked for help. Anyhow, will start by copying what I wrote and prettying it then I will try to comment the lines for you.
#TR {^You still need the following~:$} {
;creates a trigger for detecting start of list
#T+ CaptureQuestList
;turns on the capturing class
QuestList=""
;clears the variable so the capture can populate it
#ALARM {+10} {#T- CaptureQuestList}
;emergency shut off of the capture class
}
;end of trigger
#AL ParseQuestList {
;creates the alias to convert the questlist variable to the qitems variable in the format you specified
QItems="q"
;initializes qitems
#WHILE (@QuestList!="") {
;loops through until the questlist has been emptied
#IF (%pos("|",%word(@QuestList,1) {
;checks to see if the first word of the questlist
;is then end of an item. words are spereated by spaces
;and list items are sperated by |
QItems=%concat(@QItems,%item(@QuestList,1),";q")
;it was the last word of the item so we tack the
;whole word onto qitems, also the | indicates there
;another item so we will prep qitem for that
#DELNITEM QuestList 1
;gets rid of the word we just copied and the |
} {
;end of if last word of item and start of else
#IF (%numwords(@QuestList)=1) {
;check to see if only one word is left
QItems=%concat(@QItems,@QuestList)
;only word left so we tack that on to qitems
QuestList=""
;make sure the list is null so the while will end
} {
;end of if last word in list and start of else
QItems=%concat(@QItems,%left(%word(@QuestList,1),1))
;your format seemed to be q???word so this tacks on the first letter of the first word
;could be shortened to first letter of list to get faster proccessing
QuestList=%trim(%remove(%word(@QuestList,1),@QuestList)
;remove the first word and trim spaces from list
}
;end of else first word
}
;end of else last word
}
;end of else last word in item
}
;end of while
;oh look i forgot a } not much surprise here
#CLASS CaptureQuestList
;class command sets default class for creation
;this is here because it was designed so you could just copy and paster to the command line
#TR {^(*).$} {#ADDITEM QuestList {%1}}
;makes trigger to capture most of the line and populate questlist
;just caught that there can be duplicates you will have to change this
;to handle them since ADDITEM will not make dups
;use QuestList=%additem("%1",@QuestList) instead
#TR {^$} {
;trigger on blank line see noop comment below
#IF (@QuestList!="") {
;check to see if questlist has got something
;might have recieved an extraneous blank line and
;don't want the capture shut off too soon.
#T- CaptureQuestList
;ok list had something shut off capture
ParseQuestList
;execute parsing
#NOOP I am assuming a blank line follows the list.
}
;end of blankness check
}
;end of trigger
#CLASS 0
;resets default class to none.
That got really long really quick. Obviously you can't copy and paste it like that. |
|
|
|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sat Feb 09, 2002 9:56 pm |
I tried it again, and I would copy paste what it did, but I could not get the loop to stop, I tried #killall, #connect, #killall;#connect, #disconnect, #killsall;#disconnect, but it just kept scrolling #IF | each time it recieved a line from the mud, until I got an parsing error, and fault application error or something.
RaZ |
|
|
|
iljhar GURU
Joined: 10 Oct 2000 Posts: 1116 Location: USA
|
Posted: Sat Feb 09, 2002 11:00 pm |
The alias ParseQuestList is missing 2 closing parentheses. The line that reads:
#IF (%pos("|",%word(@QuestList,1) {
should be:
#IF (%pos("|",%word(@QuestList,1))) {
Iljhar |
|
|
|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sat Feb 09, 2002 11:47 pm |
I followed your instructions and adding in the 2 extra )), now when I type questparselist, and hit enter to exectute it...nothing happens....I know the triggers are all set up and are storing it to @questlist, but the alias does nothing, I typed
#alias parsequestlist
and got:
Alias: ParseQuestList QItems="q";#WHILE (!="") {#IF (0) {QItems=;q;#DELNITEM QuestList 1} {#IF (0=1) {QItems=;QuestList=""} {QItems=;QuestList=}}}
is that how it should look or did something not work right?
RaZ |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Feb 10, 2002 1:58 am |
Thanks Iljhar. I didn't catch those )'s. I really do hate trying to type out a portion of script in the non pretty format. So lets try again with the typos fixed.
#AL ParseQuestList {QItems="q";#WHILE (@QuestList!="") {#IF (%pos("|",%word(@QuestList,1))) {QItems=%concat(@QItems,%item(@QuestList,1),";q");#DELNITEM QuestList 1} {#IF (%numwords(@QuestList)=1) {QItems=%concat(@QItems,@QuestList);QuestList=""} {QItems=%concat(@QItems,%left(@QuestList,1));QuestList=%trim(%remove(%word(@QuestList,1),@QuestList)}}}}}
Try copying and pasting it that way. Then check it in the settings editor and see if it reports any syntax errors or looks like it expanded some of the variables. Reading through my second post you will see I commented that I forgot the final } on the parse alias and because of this when you pasted it portions got expanded that should have been and the whole thing got fragged. It should like rather like the pretty version in my second post when viewed in the settings editor. |
|
|
|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sun Feb 10, 2002 2:35 am |
A syntax err came up on the last } in the alias, I deleted it and hit save, and it changed the parsequestlist alias to...
QItems="q"
#WHILE (A golden harp|An onyx bracelet|The Vibroblade|A strange white skull!="") {#IF (0) {
QItems=qA golden harp
q
#DELNITEM QuestList 1
} {#IF (9=1) {
QItems=qA golden harp|An onyx bracelet|The Vibroblade|A strange white skull
QuestList=""
} {
QItems=qA
QuestList=golden harp|An onyx bracelet|The Vibroblade|A strange white skull
I have no idea what it should look like....
Do you think it would be easier if I made a text file that had the format
The Vibroblade|qtvibroblade
had all of them listed out...theres 218 different ones
and use the %grep and %item functions?
and then incorporate that in the with #addi command?
RaZ wanting to learn how to script :) |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Feb 10, 2002 3:21 am |
The whole problem is in the copying and pasting. Open the settings editor, select the ParseQuestList alias. Click in the Value box. Press Ctrl-Home. Press Ctrl-Shift-End. Press Delete. Copy this:
QItems="q"
#WHILE (@QuestList!="") {
#IF (%pos( "|", %word( @QuestList, 1))) {
QItems=%concat( @QItems, %item( @QuestList, 1), ";q")
#DELNITEM QuestList 1
} {
#IF (%numwords( @QuestList)=1) {
QItems=%concat( @QItems, @QuestList)
QuestList=""
} {
QItems=%concat( @QItems, %left( @QuestList, 1))
QuestList=%trim( %remove( %word( @QuestList, 1), @QuestList))
}}}
Paste in into the Value box. Hit save and see the results. There was another typo in the original, a ) was missing. I really don't want to hear anymore about this cause I followed all my above directions exactly then gave it a test run and it ran perfectly. |
|
|
|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sun Feb 10, 2002 3:52 am |
I really appreciate you trying but it simply isn't working past temporarily storing the long names of all the items to the variable.
--------------------------------------------------------------------------------
[26650/26650 7400/7400 7400/7400|1550 1552 -1190|4263|The Temple of Midgaard|155]
[nesu][31835394]
complete card
You still need to find the following:
A golden harp.
An onyx bracelet.
The Vibroblade.
A strange white skull.
[26650/26650 7400/7400 7400/7400|1550 1552 -1190|4262|The Temple of Midgaard|155]
[nesu][31835394]
--------------------------------------------------------------------------------
I typed #sh @questlist and:
A golden harp|An onyx bracelet|The Vibroblade|A strange white skull
appears on the screen, I type in ParseQuestList and nothing happens, I don't know what you did to test it, but its not working for me and its not the "copy and pasting" thats wrong, Is ParseQuestList supposed to be able to execute the commands or save them somewhere? At the moment it does nothing when used.
In settings editor I looked at the triggers and in the one, this came up
#IF (!="") {#T- CaptureQuestList;ParseQuestList;#NOOP I am assuming a blank line follows the list.}
^ syntax error
the ^ was directly under the ! in the #IF {!-""}
If you do not wish to help any further please say so, and if so could someone else please help?
RaZ |
|
|
|
RaZ Beginner
Joined: 04 Feb 2002 Posts: 13 Location: USA
|
Posted: Sun Feb 10, 2002 4:38 am |
Yay..after many hours of pulling my hair out, I finally figured out how to fix it myself.
I copied the script settings into an html editor, replaced some things so that it had
#addi qstuff { before each item, in each trigger, then added an extra } at the end of it.
the used
#key key9 ({#sh @qstuff)(%item(@qstuff, 1)}(%item(@qstuff, 2)}(%item(@qstuff, 3)}(%item(@qstuff, 4)}
and it works 100% how I wanted it to, then once it gets the command.
This questcard has been completed, it does qstuff=""
I really really appreciate your patiences in trying to help me!! Thanks for trying though :)
RaZ |
|
|
|
|
|
|
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
|
|