if you substitute :local with :global then everything works. When I try to define local variable it is not shown in :environment print, but all global variables are.
You will find when you get into heavy scripting. Some of the sytax scripting process was changed some in v 3.X So some scripts that worked for 2.9.X mite not work for 3.X. Just in case you didnt know. -Jordan
I suppose you were typing these commands in console, when you do that each line is like one script, but in v3.x local variables are accessable only within one script.
Try to paste this code in console then it should work: