strsplit delimiter issue
lua Code:
This is ending up printing realm, but not the name. I'm pretty sure I'm just the delimiter, but everything I've tried so far has just screwed it up more. |
I don't see anything wrong with it...
What do you get when you do print(UIDropDownMenu_GetText(CFM_LoadBox))? |
Quote:
The print() return the selected value like it should (Blackwing Lair - Chaosinc). However, I tested this before with settings saved from my mains (Thunderlord). I just attempted the same code on my "test" realm that has two names and it prints the realm's two parts as the two returns instead. realm = Thunderlord returns: Thunderlord realm = Blackwing Lair returns: Blackwing Lair |
trying escaping the "-"
eg " %- " EDIT: tested it and it doesnt work :( maybe use msg:match() ? |
strsplit()'s first argument must be 1 character long. If it is longer than 1 character, then ANY of the characters are treated as a delimiter. In your example
Code:
local realm, name = strsplit(" - ", UIDropDownMenu_GetText(CFM_LoadBox)) Code:
"Blackwing", "Lair", "", "", "Chaosinc" If you are splitting "Barthilas - Xinhuan" then you basically get Code:
"Barthilas", "", "", "Xinhuan" What you really want is this Code:
local realm, name = string.match("Blackwing Lair - Chaosinc", "(.+) %- (.+)") |
Quote:
|
All times are GMT -6. The time now is 05:14 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI