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?
|
:rolling eyes:
Okay... I mean you are the nicest guy. So I'll try to improve and just for you I edited the post. Sorry about that. I had no idea that would be an offensive analogy. Thanks for pointing that out. Oh I forgot this old post I never finished. https://www.esoui.com/forums/showthread.php?t=9304 |
Quote:
|
Quote:
Simple answer: If multiple guys tell you the same (not attack but criticize you) it would be time to reflect and think about you actually being the problem and improve on it? Especially if the ones telling you that, directly, are the ones posting the most answers and helping around here since years! Beside that many others have answeres the same to you already before, like "It was said above alreay, read?" etc. If this is nothing you understand OR want to understand, you should leave this forum. If you think you COULD improve, please try to and read more sincerely and at least SHOW by your answers then you did read and only got detail questions on 1 of the provided links, go more to detail and do not let us always do so. "Take your time there" that's what Sharli was about to say with the "squirrel comparison", and he is right even though the words were maybe wrong. About the linked other threads: ALL SAID HERE NOW, please do not go on with sarcastic postings and linking other threads as evidence of "what was wrong or not" as this would only leed to more hate... If you feel something needs to be clarified then please write private message, or better let it be and reflect now. |
just... WOW
Im not upset about this at all, its more funny than anything. I've said nothing other than ask for help. If he cant HANDLE that then he shouldn't respond. plain and simple And bear you defending him for being like that just because you likely need his help here is concerning. Noone is forcing anyone to respond and it seems like there's only 2 or 3 left that do, rest probably ran for the hills long ago and for good reason. After I first joined for example I commented on Inventory Insight that it would be kewl if he added some "get ttc pricing" that I found on the ttc page. I thought It would have been amazing, without knowing or realizing he was also the author of MM. He imediately called me mean and deleted my posts which took me weeks to even understand why. That was our 1st interaction. |
Quote:
I can attest from experience (also started with no coding background) that the community around esoui/ addon development is very nice and forthcomming. It is sad, that just because somebody says something you disagree with (in this case baertram) you automatically assume an alternative motive.... thats not a good approach. I completely understand the frustration some people display with you in the forum. Generally asking questions is nothing bad, and is what the forum is for but:
So I agree completely with Baertram, you need to reflect a little on how you use the forum. |
Quote:
I have considered and maybe I should make a small alternate addon for testing small functions and stuff like that. My point was I have no hostility to anyone in this thread but have myself been somewhat attacked multiple times. it is better to just not answer someone if your feeling hostile imo and noone is forcing anyone to answer anything. |
Without wanting to blow that up even more, just 1 example how your answers read to me (and I'm really glad that ExoY also seems to have noticed the very same, as his lists concludes about what I got the impression of too):
Quote:
Quote:
It's like accusng me for being "on the other side". But "We got no sides here". It's just that you are opening these sides with your reactions to our critic, like a "mental blockade: They are against me!". As I wrote above ExoY already summarized that pretty good, thanks for that. I'm no native English speaker so it's hard for me to do it that way. And you also answered to that how to improve in the future, which is a good reaction, thank you. |
Quote:
Especially the lua tutorial and wiki pages. I just did a small experiment and started a google search with "lua string" and every other subsequent search was only "allowed" if I read the term on a previous found page. (Trying to simulate a google search of somebody who doesnt know any of the terminology). It took me less then 10minutes to get to the page, Sharlikran posted. (On which, as mentioned before is the capital S actually mentioned) I am not doubting the amount of time you invest in researching stuff, but suggesting to rather go into detail with a few rather to click through many. Just as an advise for future google searches |
@sinnereso
In your code "value" is the string to search in and "zoneName" is the value to search for. So, you do search for "Galen" in "Tel Galen" and not the other way round. "value" should be the first parameter. Just sayin' |
eso lua refrences for you @sinnereso
1 Attachment(s)
extract this zip, and in the docs folder are HTML pages with lots of useful knowledge
|
I do thank you all for the advice and help.. It has helped me greatly both learn lua and get my addon working the way I vision it to.
This all started with me thanking for the compliment and had no intentions of it dragging out like this. I did realize after some time and posted it here that reversing "zoneName" and "value" might be a solution but I halted that realizing it would only be a bandaid fix for only the galen/tel galen issue and might equally cause the same effect in reverse. I decided the zoneName == blacklist(value) or similar solution was the best one for my needs so long as I have a complete accurate list. I up until now have preferred to avoid lists as I was weak in them and keeping them updated might be a pain but for this one exception I've decided to go ahead with it. And bear.. I do realize assuming is never good thing but I was looking for motives for completely skipping past the name calling in which I only "thanked for the compliment" right to defending someone that wasn't even being attacked, they only assumed they were. I've had enough of all this anyway. Thank you all for the help! You've been wonderful! God Bless!! |
All times are GMT -6. The time now is 01:56 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI