Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ wait.regexp confused me
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Stwau
(2 posts) Bio
|
| Date
| Sun 18 Jan 2015 01:43 AM (UTC) |
| Message
| I'm a newbie for mushclient and have read a lot of article about wait.regexp, but still can not understand it.
I wrote a script, please help me to classify the error.
function status:updateHP()
s_match1 = "^·精血·\s+(\d+)\s+/\s+(\d+)\s+\((\d+)%\)\s+·精力·\s+(\d+)\s+/\s+(\d+)\((\d+)\)";
s_match2 = "^·气血·\s+(\d+)\s+/\s+(\d+)\s+\((\d+)%\)\s+·内力·\s+(\d+)\s+/\s+(\d+)\(\+(\d+)\)";
s_match3 = "^·食物·\s+([\d.-]+)%\s+·潜能·\s+(\d+)\s+/\s+(\d+)";
s_match4 = "^·饮水·\s+([\d.-]+)%\s+·经验·\s+(.*)\s+\(([\d.-]+)%\)";
world.Send("hp");
wait.make(function()
local i;
i = 10;
while (i > 0) do
i = i-1;
local l=wait.regexp(s_match1|s_match2|s_match3|s_match4, 5);
if l==nil then
self:updateHP();
return;
end
if string.find(l,"精血") then
print("function: updateHP - string is matched:"..w[1]);
end -- end of if
end -- end of while
wait.time(5);
end); -- end of wait.make
end -- end of the function: updateHP
Does regexp function only match one pattern at one time? Should I send("hp") before or after regexp function.
When I try this script, it seems that loop dead. | | Top |
|
| Posted by
| Stwau
(2 posts) Bio
|
| Date
| Reply #1 on Sun 18 Jan 2015 02:31 AM (UTC) |
| Message
| Already solved it.
Thanks. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Sun 18 Jan 2015 06:31 AM (UTC) |
| Message
|
local l=wait.regexp(s_match1|s_match2|s_match3|s_match4, 5);
String concatenation is done with "..". |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,089 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top