ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   List of special characters for wildcards? (https://www.esoui.com/forums/showthread.php?t=10532)

sinnereso 05/01/23 04:36 AM

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 = {
                "Eyevea",
                "The Earth Forge",
                "Vateshram Hollows",
                "Maelstrom Arena",
                "%Outlaws Refuge%", <<<<<<<<THIS is the one im referring to specifically
                "Norg-Tzel",
                "Heart's Grief",
                "Ancient Carzog's Demise"
        }

for _, deadZone in ipairs(deadZones) do
    if GetUnitZone(playerID) == deadZone then
          blah blah blah
    end
end


Baertram 05/01/23 05:04 AM

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

sinnereso 05/01/23 05:19 AM

oh kk I was just reading those but wasn't sure if they apply to eso. TY

Baertram 05/01/23 10:49 AM

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.

sinnereso 05/01/23 11:00 AM

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

Baertram 05/01/23 11:11 AM

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:
  1. local myTableToCheck = {
  2.      [zoneIndexOfBalFoyenHere] = true,
  3. }
  4. if myTableToCheck[GetUnitZoneIndex("player")] then
  5.  ---player is in that zone
  6. end


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.

sinnereso 05/01/23 11:20 AM

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 :)

Baertram 05/01/23 11:25 AM

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!

sinnereso 05/01/23 11:29 AM

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 = {
                "Eyevea",
                "The Earth Forge",
                "Vateshram Hollows",
                "Maelstrom Arena",
                "Outlaws Refuge",
                --"Dark Brotherhood Sanctuary",
                "Norg-Tzel",
                "Heart's Grief",
                "Ancient Carzog's Demise"
        }
for _, deadZone in ipairs(deadZones) do
        if string.find(GetUnitZone(playerID), deadZone, 1, true) ~= nil or IsUnitPvPFlagged(playerID) then

is what im hoping will work out

Baertram 05/01/23 11:45 AM

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

sinnereso 05/01/23 11:54 AM

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