Gateway Scripts - Using variables from one script in another

Absolutely just pass them as parameters to your next script.

def function1():
     # really long script here
     variable1='blah'
     # etc with what you need to pass
     someOtherLibraryScript.function2(variable1, variable2)

and then in your other function

def function2(param1, param2):
    # param1 now has value of variable1 from script 1
    # param2 now has value of variable1 from script 1

How long is your script exactly? I would highly recommend trying to break it down to smaller scripts. Take a look at this post for an example system.util.invokeLater or alternative function in global script? - #6 by bkarabinchak.psi