Page 1 of 1

string find stuff help

Posted: Thu Dec 03, 2015 4:46 pm
by beanybabe
Three words in system message, how do I read this line and get the order I need to perform an action for each of the words in order they appear. I used some code of lisa to get the system message.

Tense bow -- alt+1
Stab -- alt+2
Attack -- alt+3

WARNING_MESSAGE |cfffff266Make the following movements in the given order:StabTense bowAttackAttackStabTense bowTense bow|r

for this I need alt2 alt1 alt3 alt3 alt2 /// alt1 alt1 only 5 used to complete

Re: string find stuff help

Posted: Thu Dec 03, 2015 8:42 pm
by lisa
Where you posted this had absolutely nothing to do with the topic, so I made a new topic just for you.

Re: string find stuff help

Posted: Fri Dec 04, 2015 3:36 am
by beanybabe
The code of yours was in that thread that gave me the message.
I searched some lua programming and found something on findstring(), I need to search each word and some how sort it or something. I have seen people working on other code with messages for the season events I hoped one may have a clue. I will try to figure this out this daily, later I need to finish recovering some code I wrote for daily's functions.

http://lua-users.org/wiki/StringLibraryTutorial this seems to be what I need I will experiment with it some.

Re: string find stuff help

Posted: Sat Dec 12, 2015 5:12 pm
by lisa
You have StabTense bowAttackAttackStabTense bowTense bow and you want to work out the order of Stab, Tense bow and Attack?

The link you provided has the answer you need, string.find.

Code: Select all

Command> local pos, endpos = string.find("StabTense bowAttackAttackStabTense bowTense", "Stab",1) print(pos) print(endpos)
1
4
Command>
So you have the position of the first occurance of Stab and when the string ends you are looking for, the 3rg argument is the position you start searching in the string, so use the info you got from the last search and search again.

Code: Select all

Command> local pos, endpos = string.find("StabTense bowAttackAttackStabTense bowTense", "Stab",4) print(pos) print(endpos)
26
29
and then use the that again for the next search

Code: Select all

Command> local pos, endpos = string.find("StabTense bowAttackAttackStabTense bowTense", "Stab",29) print(pos) print(endpos)
nil
nil
You now have a nil return which means there are no more occurrences of the string "Stab"
So you now know "Stab" is located at postion 1 and 26 of that string.

That is as much as I am going to say, the rest should be easy enough for you to work out.

Re: string find stuff help

Posted: Sat Dec 12, 2015 11:03 pm
by beanybabe
the_error = WARNING_MESSAGE |cfffff266Ma...
Sorry the original tread somehow showed me how to get that message.
I cannot find an example of how to get the error into a variable.
so I can use the string function to find the action.

The eoj and other code samples find just test for the error but do not capture it to a variable.

Re: string find stuff help

Posted: Sun Dec 13, 2015 8:45 am
by lisa
and what happens when you print the_error ?
print(the_error)
It more than likely prints it on MM because it is a string.

Code: Select all

local pos, endpos = string.find(the_error, "Stab",1) print(pos) print(endpos)
 

Re: string find stuff help

Posted: Sun Dec 13, 2015 9:26 pm
by beanybabe
forget the rest of this thread.

I go to npc, accept quest, then start, a second or 2 later: it post a message that is a warning. I need to get this into a Variable.

After that I can try to write the string code.