Thread Tools Display Modes
05/07/15, 05:07 AM   #1
Leju
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 8
Lua - Get Directory xxx.lua

I am creating an addon and I'm stuck on one thing, when I use the following line in the Lua
local dir = debug.getinfo(1).source
it returns me the following result
@game:/EsoUI/lang/br_pregame.lua
and what I need to know and exactly the way it is "@game:" by chance would have the game function something that could help me?

Last edited by Leju : 05/07/15 at 05:25 AM.
  Reply With Quote
05/07/15, 05:45 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,034
Do you need to know the value "behind" @game (the directory of the game, like c:\programs\elder scrolls online\game), or do you just need the string @game: separated from the total string @game:/EsoUI/lang/br_pregame.lua
?
  Reply With Quote
05/07/15, 06:14 AM   #3
Leju
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 8
I need this path
C:\Users\<<User Name>>\Documents\Elder Scrolls Online\live\AddOns
but it returns me just that damn @game: if it be fixed would be no problem but the user can change the default folder for documents elsewhere, which is why I'm behind a solution covering the maximum possible scenarios.
  Reply With Quote
05/07/15, 06:28 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,034
Ok. it looks for me that @game: is used internally the elder scrolls online as a "constant" for the correct game path.
Aren't you able to just use this @game: value too in your addon then?

Other question:
What do you need the path for? As far as I know the ESO lua codes do not support any I/O part of normal lua so I don't think there is any possibility to get the correct file path.

I'm not at my gaming pc at the moment so I cannot check this:
Maybe the path is saved somewhere in the C:\Users\<<User Name>>\Documents\Elder Scrolls Online\live<eu>\UserSettings.txt" file as a full string? Did you look into this file already?
There you would be able to read the settings information then to parse the string.

Check this thread how to read the settings:
http://www.esoui.com/forums/showthre...light=settings

EDIT:

Just found an example of usersettings.txt online and it seems it is using the same game:/ value there....
Code:
SET LanguageDirectory.2 "game:/EsoUI"
So parsing this won't help, too bad.
But I still think you could just use the same constant "game:/" in your addon too then.



Question:
What do you want to achieve? Maybe there is a nother way to do this by using your addons base path and using ../../ to go up some folders etc. ?

Last edited by Baertram : 05/07/15 at 06:33 AM.
  Reply With Quote
05/07/15, 07:03 AM   #5
Leju
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 8
Okay let by XD

1 Agree with you on the part of "@game:" being a constant and used internally and has tried to use only "@game:," and it did not work!

2. Support for I/O is partially right, I found that if you run Lua codes while the game loads you fully supports the Lua commands, my intention and create a kind of eastereag in the game where you will see a splash screen with the name of the translator for PT-BR version (original game splash will be kept)

3. I checked for UserSettings.txt could be something to help me, but unfortunately found nothing!

4. I tried using the "@game:" direct or checking through various existing functions in ESO to return me something but all in vain!

5 I wanted to create a splash screen to show the employees to translate just about everything already iss ready so lacking copy the .bik video Addon folder for "The Elder Scrolls Online\depot\Video" discover what is ready below

Lua Code:
  1. function file_exists(name)
  2.    local f=io.open(name,"r")
  3.    if f~=nil then io.close(f) return true else return false end
  4. end
  5.  
  6. function PTBR_LoadMedia(event, name)
  7.     local dir_MidiaBR = "TraducaoPortuguesBR/Media/BR_logo.bik"
  8.     if file_exists(dir_MidiaBR) then
  9.         os.remove("../../depot/Video/BR_logo.bik")
  10.         os.rename(dir_MidiaBR, "../../depot/Video/BR_logo.bik")
  11.     end
  12.  
  13.     PlayVideo("Video/BR_logo.bik", false, 1)
  14.     os.remove("controlador.dat")
  15. end
  16.  
  17. GetEventManager():RegisterForEvent("TraducaoPortuguesBR", EVENT_ADD_ON_LOADED, PTBR_LoadMedia)

Just missing the place that is the video that will be placed in the variable "dir_MidiaBR" to put the full path
  • D:/Documentos/Elder Scrolls Online/live/AddOns/TraducaoPortuguesBR/Media/BR_logo.bik
It works just right
  Reply With Quote
05/07/15, 07:08 AM   #6
Leju
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 8
because to use playVideo is required is within the video "The Elder Scrolls Online/depot/Video" already tried running other folders simply does not.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Lua - Get Directory xxx.lua


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off