line 6, in function2 NameError: global name 'function1' is not defined
line 9, in function3 NameError: global name 'event' is not defined
line 12, in function4 NameError: global name 'system' is not defined
Do not use def inside gateway event scripts. In my not-so-humble opinion, you should not use def (or import) in any event script. Make a one-line call to a project library script, passing any necessary arguments in the function call. Always.
[quote="pturmel, post:2, topic:112058"]
Make a one-line call to a project library script,
[/quote]
me, wanting to skip the explanation why I have such script in project library to team lead, and skip the decision of a proper place to store it in Project Library.
For posterity (I know Phil knows this, but for the OP and anyone who comes across this thread in the future) - that legacy scoping issue is fixed in 8.3.0 and up.