List of special characters for wildcards?
Hey guys this might seem like a dumb question but I'm looking for a list of special characters with some descriptions of how they work with eso.
Symbols like % and ? and * etc etc. I'm fine tuning my addon and made a table of locations you can't travel to but would like to use a wildcard for "*Outlaws Refuge" for example. In the following example whats the easiest way to achieve this? I'm looking to use a wildcard at the beginning of "%Outlaws Refuge" to HIT on any places like "Wayrest Outlaws Refuge". Code:
local deadZones = { |
For that you need to use string pattern functions like string.find and string.gmatch etc.
https://www.lua.org/pil/20.1.html https://www.lua.org/pil/20.2.html |
oh kk I was just reading those but wasn't sure if they apply to eso. TY
|
https://wiki.esoui.com/New_to_lua%3F_GOTCHA
ESO uses lua, lua 5.1 though changed for the game's engine, with some lua 5.2 and 5.3 functions added. |
been going over those pages all day and they appear to do the reverse of what I need. for example im needing to match the end of
GetUnitZone("player")--- which lets say is "Bal Foyen" with an item in the table local table = { "foyen" } id like to easily in the for xxxxxxxxx do statement if GetUnitZone("player") == *table item not know how many occurences etc of it there is. **EDIT Nevermind I just realized they will never be equal. at best the table will return Foyen not Bal Foyen. Ill rethink it some more =p |
At first: Unit and zone names can end on e.g. ^m or ^p or similar which shows (for non en language) the gender of the text to add the correct article.
So you should first remove those by using lcoal nameClean = zo_strformat(SI_UNIT_NAME, GetUnitName("player")) e.g. And if you want to check for zones why don't you simply use the zoneIndex, which are language independent "always the same numbers", and thus way easier to check for? Lua Code:
If you need to check that the player is in the zone, even though she/he is in a subzone like a delve, check the other API functions like GetParentZoneId() and so on to maybe get the parent zoneId (should be the top zone's ID then, not the one of the delve anymore). Not sure what your usecase is and what you need to check and get, but string comparison is slow, and error prone. Better use the index and id functions instead as no translation or similar would be needed. |
hmm.. thats an interesting way to do it.
Where This became an interest to me was teleporting to saved player in any Outlaws Refuge. as I was adding locations to my table you cant teleport to I came across these which are many so I thought I would have my if statement see if the target players location "ends" in any of the table entries so I could just list "Outlaws Refuge" in there to cover them all. This is kinda my 1st active table ive created from scratch without any peeking around so its going slow :) |
Yeah, such refugees got several zoneIds, depening on the map they belong to. But I'm not sure if their zone name always got that "outlow refugge" yu could check for.
if you want to do this you could use if string.find(stringToSearch, "outlaw refugee", 1, true) ~= nil then --found end The last pattern will make it search with plain text, without any patterns! If it returns something not nil it will return the position in the string where it was found. -> You must use stirng.lower(stringToMakeLowercase) on the stringToSearch first to make it match the lower case "outlaw refugee" then! |
PERFECT! I think that will do the job for any of the entries including outlaws refuge's. I'll give it a whirl
Code:
local deadZones = { |
You can easily find out other language names too by switiching the language ingame via (merTorchbug updated installed!):
/tblang <2CharLang> <2CharLang> can be: de en es fr ru zh --Chinese /tblang en will bring you backt o English then. Simple and nothing damaged,. Better disable all other addons though, only your 1 own you work on enabled + merTorchbug and helper tools like LibDebugLogger e.g. Makes loading screen fast. That way you can String see results of the same API functions and can copy the texts (you can use pChat e.g. to make right clicking chat entries -> copy line simple, or use DebugLogViewer so that messages of the API functions raised via /tb GetUnitZOne("player") or /script .... to that UI where you can copy them 1:1 from via mouse mark and CTRL+C In your addon check for the current client language via: local clientLang = GetCVar("language.2") Will return something liek de, en, fr then. And you can make your table multilanguage that way: local deadZones = { ["en"] = {...}, ["de"] = {...}, ["fr"] = {...}, ... } And access it via local deadZonesToCheck = deadZones[clienLang] or deadZones["en"] --fallback language English for i=1, #deadZonesToCheck, 1 do if string.find(string.lower(stringToSearch), deadZonesToCheck[i], 1, true) ~= nil then --found, either use break to exit the loop or return to exit the function return true end |
wow thank you.. ill be honest I knew at some point other langages was going to need to be a thing but I haven't got there yet. Im currently struggling with my own with this haha. Ill save this for that future endeavor when I'm ready. Im still learning all this so this addon is also my reference of examples of many many things while it all sinks in.
*EDIT THANK YOU! its working perfectly! Now i can go all around and test easily too |
All times are GMT -6. The time now is 10:18 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI