04-16-11, 12:24 PM | #1 |
Got a problem comparing strings
Hi
My AddOn does compare an yell message with a database of pre defined strings. The problem is that while fighting Anraphet, for example, the first yell, the long one, doesnt work, but hte other are working. Rajh on the other hand doesnt work at all and I dont have any idea why. I dont get any LUA-Error if this occurs. lua Code:
I can see "ana" or "rajh" everytime one of them yells. but "bsp_datasoundfile" is nil predefined: lua Code:
Last edited by SignOfDoom : 04-16-11 at 02:50 PM. |
|
04-16-11, 02:30 PM | #2 | |
The first block of code, I don't see any problem with. From what you're describing, it's matching the mob, but none of the messages. Possible things to check would be spelling or spacing. The first few times you're checking a message against a stored string, you'll run into a few problems trying to get them to match so it'll work.
To clean it up a bit and possibly to expand, you should look into looping the check. lua Code:
The second block of code, I'm noticing that all the keys for "Rajh" are all 1. To make it a little easier, if all the keys are sequential, you don't need to define them. Just make sure the order matches and they'll get the correct keys. For example, these produce the same result. lua Code:
lua Code:
Also, be mindful of other addons running as well that might interfere with your code. I would suggest breaking away from the L namespace and work with your own. This table is commonly used in Ace addons for localizations and changing the common format for your own may break other addons or cause yours to break due to conflicts.
__________________
WoWInterface AddOns
Last edited by SDPhantom : 04-16-11 at 02:47 PM. |
||
04-16-11, 02:36 PM | #3 |
i didnt noticed that rajh had only "1s". I also thought about building in a for loop, but i think my way will be enough for the mooment. but this does not cause the problem.
i would just hear the same sound for every yell this is the code wich uses these functions: lua Code:
lua Code:
Last edited by SignOfDoom : 04-16-11 at 02:54 PM. |
|
04-16-11, 02:55 PM | #4 |
May i suggest a simpler code structure:
Lua Code:
The sound files can then be accessed as follows Lua Code:
Though the function probably isn't even necessary anymore. Edit: changed the L.rahj to L["rajh"] since it has to be a string. Last edited by daylesan : 04-16-11 at 03:02 PM. |
|
04-16-11, 05:03 PM | #5 |
I still dont know what caused this problem but after i minimized the code (tanks to daylesan) everything i tested till now works.
Does someone know if there is a maximum lengh of a tabke key? |
|
04-16-11, 05:45 PM | #6 | |
There shouldn't be.
Here's what I have so far: localization.lua lua Code:
bsp.lua lua Code:
This should work as long as all the strings match up. Make sure you load localization.lua before bsp.lua. This code has no global footprint and uses the shared table WoW creates specifically for your addon
__________________
WoWInterface AddOns
Last edited by SDPhantom : 04-16-11 at 05:50 PM. |
||
04-16-11, 06:07 PM | #7 | |
|
||
WoWInterface » Developer Discussions » Lua/XML Help » Got a problem comparing strings |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|