Nick Gammon said:
Hmmm, there is a sort-of a bug there. Notice this:
http://www.gammon.com.au/forum/?id=7336
It seems this is a known issue, and the addxml plugin works around this by doing this:
function trigger (t)
GeneralAdd (t, "trigger", "triggers")
-- force script entry-point resolution
if t.name and t.script then
SetTriggerOption (t.name, "script", t.script)
end -- if trigger has a name, and a script name
end -- addxml.trigger
However to do a SetTriggerOption it has to know the name of the trigger, so if you have an unnamed trigger it can't do that.
So your workaround is to give the triggers names, even if you just generate one randomly, or use GetUniqueNumber or GetUniqueID.
Mind you, generally you shouldn't need to add triggers on-the-fly like that.