Scripts lua a créer

hi there, Im trying create a script lua hooked but first it doesnot appear and then it doesnot work in the editor. Maybe I will find who wil save me. My script must react on load session, save session. It seams to be easy but I’m novice et I don’t find any tuto on that.
My script: ardour {
[“type”] = “EditorHook”,
name = “Record Now”,
license = “MIT”,
author = “Ardour Team”,
description = [[Engage Global Record-Arm and Play (record - roll)]]
}

function signals()
local s = LuaSignal.Set()
s:add(LuaSignal.SessionLoaded)
s:add(LuaSignal.SessionSaved)
s:add(LuaSignal.SessionClosed)
return s
end
– local LuaSignal = require(“ardour.LuaSignal”)
function factory(params)
return function(signal, ref, …)
print("Patchage créé avec connexions en cours : ")
– local session_path = Session:path()
– local patch_file = session_path … “/patchage.snap”

– if signal == LuaSignal.SessionLoaded then
– Charger le patchage à l’ouverture
– local file = io.open(patch_file, “r”)
– if file then
– io.close(file)
– local command = “aj-snapshot -xr "” … patch_file … “"”
– local result = os.execute(command)
– if result == 0 then
– print("Patchage chargé : " … patch_file)
– else
– print("Erreur chargement patchage : " … patch_file … " (Code: " … result … “)”)
– end
– else
– – Créer le patchage avec les connexions en cours
– local create_command = “aj-snapshot -w "” … patch_file … “"”
– local create_result = os.execute(create_command)

– if create_result == 0 then
– print("Patchage créé avec connexions en cours : " … patch_file)
–# else
–# print("Erreur création patchage : " … patch_file … " (Code: " … create_result … “)”)
–# end
–# end
–# elseif signal == LuaSignal.SessionSaved or signal == LuaSignal.SessionClosed then
–# – Sauvegarder le patchage à la sauvegarde ou fermeture
–# local save_command = “aj-snapshot -w "” … patch_file … “"”
–# local save_result = os.execute(save_command)
–# if save_result == 0 then
–# print("Patchage sauvegardé : " … patch_file)
–# else
–# print("Erreur sauvegarde patchage : " … patch_file … " (Code: " … save_result … “)”)
–# end
–# end
–# end
end