I have a function called 'ProcessAddons()'
Which checks if a addon file exists and then tries to read and run it.
I expected that each time I call 'ReadDataFile(addonFile)', that the script referred to as 'addon' would be replaced internally by the one in the latest lvl file.
But I am only seeing the code from the first addon be executed. I don't know why.
A solution is to name the scripts 'addon000', 'addon001' ... [Which is kinda lame, but it works.]
Anyone know of a 'less lame' way to make this work?
Code: Select all
function ProcessAddons()
print("ProcessAddons: START ")
local addonFile = ""
for i=1,999, 1 do
addonFile = string.format("addon\\%03d\\addon.lvl", i)
if( ScriptCB_IsFileExist(addonFile) == 1) then
print("adding: " .. addonFile )
ReadDataFile(addonFile)
ScriptCB_DoFile("addon")
print("did file: " .. addonFile )
end
end
print("ProcessAddons: DONE ")
end
addon\001\addon.lvl > contents 1 script named 'addon' content => print("001")
addon\002\addon.lvl > contents 1 script named 'addon' content => print("002")
addon\003\addon.lvl > contents 1 script named 'addon' content => print("003")
------------- output --------------
ProcessAddons: START
adding: addon\001\addon.lvl
001
did file: addon\001\addon.lvl
adding: addon\002\addon.lvl
did file: addon\002\addon.lvl
adding: addon\003\addon.lvl
did file: addon\003\addon.lvl
ProcessAddons: DONE
-----------------------------------