string find stuff help

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

string find stuff help

#1 Post by beanybabe » Thu Dec 03, 2015 4:46 pm

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

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: string find stuff help

#2 Post by lisa » Thu Dec 03, 2015 8:42 pm

Where you posted this had absolutely nothing to do with the topic, so I made a new topic just for you.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: string find stuff help

#3 Post by beanybabe » Fri Dec 04, 2015 3:36 am

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.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: string find stuff help

#4 Post by lisa » Sat Dec 12, 2015 5:12 pm

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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: string find stuff help

#5 Post by beanybabe » Sat Dec 12, 2015 11:03 pm

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.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: string find stuff help

#6 Post by lisa » Sun Dec 13, 2015 8:45 am

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)
 
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: string find stuff help

#7 Post by beanybabe » Sun Dec 13, 2015 9:26 pm

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.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest