Hello,
It took me some time and some tests to understand how multiple scripts can be installed.
The sample Orthanc config file comments mention a list of Lua scripts can be defined:
// List of paths to the custom Lua scripts that are to be loaded
// into this instance of Orthanc
“LuaScripts” : [
“/Users/dwikler/Development/Orthanc_1.5.7/scripts/script1.lua”,
“/Users/dwikler/Development/Orthanc_1.5.7/scripts/script2.lua”
],
If I install 2 Lua scripts as define above (the easy part) with the scripts hereunder:
script1.lua:
function Initialize()
print(“in script 1 while starting Orthanc”)
end
function Finalize()
print(“in script 1 while leaving Orthanc”)
end
script2.lua:
function Initialize()
print(“in script 2 while starting Orthanc”)
end
When I start Orthanc, I get the following log:
LuaContext.cpp:104] Lua says: in script 2 while starting Orthanc
When I stop Orthanc, I get the following log:
LuaContext.cpp:104] Lua says: in script 1 while leaving Orthanc
This demonstrates that multiple scripts can be installed but that the Callback function for one event (the event handler) can only be defined in one of the scripts.
If defined multiple times, the event handler of the last script in the list will be used.
This makes sense.
I looked for this information in the book, faq, this group and other places without success so here it is for anyone who would look for it.
I will try to take the time to clarify this in the great Orthanc book in https://book.orthanc-server.com/users/lua.html#id2
And I take the opportunity to congratulate Sebastien and the whole Orthanc community for this great software
David