WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   In-game text editor tends to saves extra vertical slash ('|') into SV (https://www.wowinterface.com/forums/showthread.php?t=56730)

Lyak 09-30-18 04:52 PM

In-game text editor tends to saves extra vertical slash ('|') into SV
 
Hi again all :p,

So, I ain't sure where and why this is actually happening, but Input field tends to save extra vertical slash inside SV which is causing a hardship on saving things like escape sequences.

Lua Code:
  1. local testOption = {
  2.     type = "group",
  3.     childGroups = "tab",
  4.     name = "TestOption",
  5.     arg = "TestOption",
  6.     args = {
  7.         test = {
  8.             type = "input",
  9.             name = "Input",
  10.             width = "full",
  11.             get = function(info)
  12.                 return myDB.test;
  13.             end,
  14.             set = function(info, ...)
  15.                 myDB.test = ...;
  16.             end,
  17.         },
  18.     },
  19. }
  20.  
  21. ACR:RegisterOptionsTable("TestOption", testOption);
  22. ACD:AddToBlizOptions("TestOption", nil, nil);

For example, if I input |cFFFFFFFF|r



This will actually save ||cFFFFFFFF||r



Alternatively, I tried to use \124, but unfortunately, same thing still occurs.
(In this case it saves \\124, extra back slash, instead of \124 :confused::confused:)

-- EDIT #1: Changed thread title

Looks like it is not AceConfig input field specific behaviour, but text editor in general.

Xrystal 09-30-18 06:37 PM

I might be wording this wrong, so it may get corrected :)

But, the extra / in strings are usually added to show that the following / is not part of a special character called an escape code. It may be a similar thing to | but I haven't used that outside of wow programming as special functionality to know if it is used in a similar capacity.

I hope that explains it well enough for you.

Lyak 10-01-18 01:10 AM

Quote:

Originally Posted by Xrystal (Post 330312)
I might be wording this wrong, so it may get corrected :)

But, the extra / in strings are usually added to show that the following / is not part of a special character called an escape code. It may be a similar thing to | but I haven't used that outside of wow programming as special functionality to know if it is used in a similar capacity.

I hope that explains it well enough for you.

Hi Xrystal,

Now I did get the point of why it does such thing.

Thank you for your clarification :D

The next question would be, then how could I save and restore those escape sequences via in-game text editor.

Xrystal 10-01-18 04:04 AM

Not sure as I haven't crossed that bridge myself. I would have assumed if wow wrote it to the data in that format it would understand it to read it back in correctly. Have you checked if it causes a problem when reading it back out ?

Otherwise, I would probably not save them but rather check what data they point at and put them in the relevant section of the data.

EG.

|c123456|r is a color string - I would read the string, see it has a |c in it and read the following characters in and assign them the relevant color code r,g,b,a and then stop when it hits |r and save it in a color table to and replace the string with something that can be validated myself such as COLOR[key] and replace COLOR[key] with the contents of COLOR[key] when restoring the data to the screen. Of course that is just theory and may not be physically possible in exactly this way.

Maybe someone has come across this and resolved the problem, or have a work around.

Lyak 10-01-18 06:52 AM

Quote:

Originally Posted by Xrystal (Post 330315)
Not sure as I haven't crossed that bridge myself. I would have assumed if wow wrote it to the data in that format it would understand it to read it back in correctly. Have you checked if it causes a problem when reading it back out ?

Otherwise, I would probably not save them but rather check what data they point at and put them in the relevant section of the data.

EG.

|c123456|r is a color string - I would read the string, see it has a |c in it and read the following characters in and assign them the relevant color code r,g,b,a and then stop when it hits |r and save it in a color table to and replace the string with something that can be validated myself such as COLOR[key] and replace COLOR[key] with the contents of COLOR[key] when restoring the data to the screen. Of course that is just theory and may not be physically possible in exactly this way.

Maybe someone has come across this and resolved the problem, or have a work around.

Hi again Xrystal!

So, basically when I input |cFFFFFFFF|r through the text editor, then save it to SV, this will save ||cFFFFFFFF||r as I mentioned at the start. Then if I read it back (e.g. print(myDB.test)), this will print out |cFFFFFFFF|r which I'm guessing is because the client(?) is translating '||' to '|' as you've explained on your first comment.

I think I'll need a further experiment on this :p

-- EDIT #1

Alright, I think I got the temporary solution(?).

I'll just let it to save with those double slashes, but make it replace to single slash via string.gsub whenever I need to use it.

I think that's the cheapest work around haha :D!!

-- EDIT #2

Yeap, it's looking awkward, but at least it's working :banana:

Xrystal 10-01-18 12:07 PM

good to see you're getting it figured out. It's all a learning curve. I just had the added advantage of knowing some programming already. Some rules are the same regardless of how the language deals with it.


All times are GMT -6. The time now is 05:28 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI