Proper globalvar support

Handles globalvars in scripts by determining whether variable access is
local or global.