string.find or string.match question
Hey ive been having some irregularities with one of my teleport functions. Particularly with my blacklist.
I have "Tel Galen" in my blacklist and have trouble teleporting to "Galen". I guess what I'm needing is a way to exactly match not match part of "Tel Galen". Heres a sort of example of what I'm using to achieve what I have now. Code:
local _, _, memberZone, _, _, _, _, memberzoneID = GetGuildMemberCharacterInfo(guildId, memberIndex) |
Wouldnt just compare strings directly solve the problem?
Lua Code:
or Lua Code:
depending on implementation |
Quote:
|
Again: Use zoneIds instead of strings and you never get that problems!!!
Using the IDs internaly does not remove the possibilities to show the names as strings to your UI?! One day you might improve on it then ;-) |
Quote:
|
If you want the unique difference then MapId is better.
|
so far its working perfectly and havent been able to break what I have running..
I do have some questions regarding: Code:
SLASH_COMMANDS["/rd"] = function (option)--<< /RD TELEPORT TO ZONE OR SPECIFIC PLAYER HOUSE -What im trying to do with them is if theres no "options" then display a help text.. -if theres options[1] and options[2] then if it contains an "@" do my code for teleport to specific player house which its currently doing fine if there 2 words but not checking for "@" -if theres options[1] options[2] options[3]++++ then display help text I google like mad to find the meaning of thes symbols but theres some wild explanations what make it hard to make sense of. id like it todo as follows if a user or myself type these: /rd => display df("blah blah") help text /rd word => find player in zone"word" and go there /rd word word => goto specific player house if @symbol in word1 and find a house matching word2 or if no @symbol in word1 then => display df("blah blah") help text /rd word word word or more words => display df("blah blah") help text |
this seems to do what I need.. any thoughts?
Code:
SLASH_COMMANDS["/rd"] = function (option)--<< /RD TELEPORT TO ZONE OR SPECIFIC PLAYER HOUSE |
^(%S*)%s*(%S*)%s*(%S*)%s*(%S*)$
My thought, WOW! https://www.lua.org/pil/20.2.html So you are telling it to check at the beginning of the string with the ^ symbol. Group 1 you look for Zero or more non space chars. Then for the default group (which isn't really a group) you look for Zero or more spaces. Then Group 2 you look for Zero or more non space chars. The default group again for Zero or more spaces. Then Group 3 you look for Zero or more non space chars. Then a third time, the default group again for Zero or more spaces. Then Group 4 you look for Zero or more non space chars. The last group matches up to the end of the string with the $ symbol, as long as it isn't a space. The default group might actually be group 1 for Lua which means that you have 1 through 5 rather then the default and 1 through 4. |
Code:
local searchByWords = zo_strgmatch(searchText, '%S+') |
ive looked through all of those like 100x.. and amazingly this is working and sort of makes sense to me.. try it youll see.
the %S is for basically the words and the %s is for the spaces... seems to be working perfectly.. What i cant find any info on is the S in %S. But based on that example it seemed it was doing the seperate words. |
Quoting myself because you missed it.
Quote:
|
Quote:
and all im needing is /rd option[1] option[2] option[3] option[4] etc |
Quote:
Code:
local searchByWords = zo_strgmatch(searchText, '%S+') |
Quote:
Thank you for the help.. I havent come across anything that states the capitol S was the reverse which IS highly useful. |
- What is there seems to function OK for 1 or 2 words but if there a 3rd its gets wonky
- What i cant find any info on is the S in %S. But based on that example it seemed it was doing the separate words. - "^(%S*)%s*(%S*)%s*(%S*)%s*(%S*)$" So I explained what the S was and showed a way to handle 1 or more words. For some reason you are frustrated with the fact the link didn't have an S on it, which is concerning. I get you are asking but it's concerning when people ask questions and then when someone answers they put it on the person providing the answer that they did or said something wrong. Usually some rhetoric follows at some point like, "I can ask because it's the help section! Geez I'm just asking." which is just an excuse for their reaction. It's like damed if I do, damed if I don't and I'm the jerk either way. When that's not the case because I answered the question, politely, the first time. They were the ones whining about it and saying they can't figure it out. Code:
function HandleSlashCommands(allArgs) |
I didnt suggest you said anything wrong.. unless you personally feel that way for suggesting i was searching like a squirrel on crack or something for example... I do try to search for my own answers and post here as little as possible mostly for this reason. Forums are for the most part less friendly than prison. I refused to even join one for like 15yrs because I saw the kind of bantering that goes on while googling whatever it was I needed at the time... Nearly the least friendly place on the internet hands down.
If you want to help you need to be more like beartram. This guy has suffered through many of my questions and always kept his cool. You have to realize not everyone is at your level of understanding and while something you respond with might seem simple and basic, could be right out the field of view for someone else and require re-reading it many time after more research for it to click. |
Quote:
Quote:
|
Well, I had the same discussion with you a few weeks ago, and I must sayb
Yes, you search by your own and that's great. But no, you often do not seem to read the answers properly. Or you do but not going into detail, letting others (us!) do your job there... Shatlikran explained it really good, in detsil, linked the description of the lua pattern characters (yes, that uppercase S wasn't explained but uppercase was below all chars, by the A example. So maybe you missed it, or only searched for S :D). I know it's hard to lrarn new stuff but we REALLY explain alreary more than usual, even write total code for you. And Sharlikran is correct to react annoyed of one needs to repeat the same 3 times. Forums are not unfriendly. You must keep in mind that there are thousands of ppl asking stuff, many things were asked so often you do not even understand why it's not found by the next asking guys themselves. And if it feels to take like an endless anserr, with multiple repeats, it's not helping. You feel like taking against a wall then (especially if different answering devs explain, provide info AND links, and it is still ignored/not understood). So please keep that in mind and try to read the links and sources we provide more sincerely. Understand keywords klike pattern in this case here) and search on that. Google would have shown you multiple results for "lua pattern %S" (even with reddit examples where devs explain all!). Makes you learn it better/more easily, and unstresses us ppl answering here. Else you might get only 1 link next time, and have to do the research by your own (like it would be best to learn it, actually) until you find your answer and can place the next answwuestion based on it. If you feel this is not what forums should do for you you might need to go back to the friendly prison guys then :rolleyes: @Shalikran Try to strip those squirrel on crack comparisons please :p Editb Sorry for the many typos, hope it's still readable. Btw, just read that "Baertram is always nice" part: I'm not. I jusr adopt to your questions and know meanwhile how to take you, sinnereso. I really must say it's more complicated than others, but I know you got no developer background and thus it might be harder to follow at some steps. So I'm doing the extra mile, but you cannot expect that to happen from all here. So please do not compare me with others and say "you all should be like Baetram".thanks for the words but that's unfair to the others! In the end I should be more like them be let you do more homework :o |
Sharlikran: I wasn't jabbing. I'm the one being attacked multiple times now for asking a question or not understanding the answer.. Either way is that ok? Is that what this forum is for or about? Would you prefer to be here all alone knowing it all talking amongst yourself?
|
All times are GMT -6. The time now is 08:32 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI