Getting the script own name
Posted: Tuesday 15 August 2017 10:04
Hello everyone,
I am currently beginning to move all of my "standard" lua scripts to dzVents 2.2.0, and I am stuck on one thing : How get my script name...
For the story, I use a "personal" logging function, that I will use in dzVents too because I designed it to handle the "debug" mode for only one script, and not all of them as it is when you use the dzVents log level.
So I am using the helpers as explained in the wiki, in the "global_data.lua" file.
I would like to know if I can get the name of the script triggering this function, so I could write it on the log.
For now, I write in each script the following lines :
and then I use "File" as an argument when calling my function...
I have seen in "EventHelpers.lua" that the name of the module currently executed is coming from "eventHandler.name". Is there a way to use this directly inside of my own function ?
I am currently beginning to move all of my "standard" lua scripts to dzVents 2.2.0, and I am stuck on one thing : How get my script name...
For the story, I use a "personal" logging function, that I will use in dzVents too because I designed it to handle the "debug" mode for only one script, and not all of them as it is when you use the dzVents log level.
So I am using the helpers as explained in the wiki, in the "global_data.lua" file.
I would like to know if I can get the name of the script triggering this function, so I could write it on the log.
For now, I write in each script the following lines :
Code: Select all
local path = debug.getinfo(1,'S').short_src
while string.find(path, '/') do path = string.sub(path, string.find(path, '/')+1) end
local File = tostring(string.sub(path, 1, string.len(path)-4))I have seen in "EventHelpers.lua" that the name of the module currently executed is coming from "eventHandler.name". Is there a way to use this directly inside of my own function ?