Posted 12 July 2013 - 10:07 PM
Hello,
Recently when i had some defect code and started to put some prints to find the culteprit, i by accident stumbled on the following.
I have this override to fs.makeDir in my script:
Now if you put that code in a file and run it once it prints the messages as expected.
However each time you run the file again its prints out the messages equal to the amount of times you have ran the file, as if the function is somehow called multiple times.
I suspect it might have something to do with the environments, but since i just started in lua/CC my knowledge is too limited to determine what is happening.
I was wondering if theres someone out there who could explain what exactly is going on here and also if possible how to prevent this.
Regards,
Turbo
Recently when i had some defect code and started to put some prints to find the culteprit, i by accident stumbled on the following.
I have this override to fs.makeDir in my script:
local nativeMakeDir = fs.makeDir
function fs.makeDir(_sPath)
print("MakeDir check: ",_sPath)
if not fs.exists(_sPath) or fs.isDir(_sPath) then
print("Making a dir")
nativeMakeDir(_sPath)
return fs.exists(_sPath) and true or false
end
return false
end
fs.makeDir("testing")
Now if you put that code in a file and run it once it prints the messages as expected.
However each time you run the file again its prints out the messages equal to the amount of times you have ran the file, as if the function is somehow called multiple times.
I suspect it might have something to do with the environments, but since i just started in lua/CC my knowledge is too limited to determine what is happening.
I was wondering if theres someone out there who could explain what exactly is going on here and also if possible how to prevent this.
Regards,
Turbo