Once you've "finished" your artwork with Field there's often one important step left — "installing" it someplace; getting it to run by itself without supervision. While Field offers all kinds of fun and interactive ways of clicking on things and running them, how do you get the "ball rolling" all by itself?
There are a few pieces of to this puzzle and, of course, it really depends on what you are using Field for. If you are using it to write code against some Processing Libraries, you'll probably be interested in setting the embedded Processing environment to make a fullscreen canvas:
The 'p' tab on the palette lets you change this.
Of course if you are doing something else with Field (perhaps using its graphics system) there might be some other steps that you'll have to take to present a "fullscreen" face to the world.
The first kind of automatic running is built directly into Field's text editor. Using the drop-down menu t the top of the editor you can edit different properties of a box (GLSLang shaders, drawing edits and the like show up here). One of the properties is code that's run every time the sheet is loaded:
This code whenever this box "appears" — on loading a document with it in it, or on loading it as a template. The order of code execution — when you have many automatically executing boxes; is unspecified. To tweak it, use the property in the inspector:
The next step is to launch Field in such a way as to prevent any of its own windows and menus actually initializing. The most straightforward way of doing this is to learn something about launching Field from the command line. While there's more extensive documentation on these options here, we'll cull the most interesting ones into this page.
(Let's assume that you've got a Field binary release living in /Applications — if you have it someplace else you'll have to change some of the examples below.)
First, how to run Field without double-clicking on anything (if you are on the Mac). Entering this into the Terminal:
/Applications/field.app/Contents/MacOS/field_mac64.sh
is just like double clicking on the icon in the Finder (except that you'll get all manner of debug printout in your terminal and you can 'quit' by pressing ctrl-c
). 'Advanced users' might be interested in aliasing the command above to something shorter — OpenEnded group and other Field developers generally run Field from the command line this way.
Of course, if you are running Field in Linux, you don't need to do anything extraordinary to run it from the command line.
The next stage towards an auto-running "installation" is to open a particular sheet regardless of what you've selected from the File menu:
/Applications/field.app/Contents/MacOS/field_mac64.sh -field.scratch mysheet.field
Executing this will open Field in pretty much the same way as if you'd double-clicked on a .field file that's in your workspace. Note that if "mysheet.field" doesn't exist it will be automatically created.
The next thing to do is to get something to actually auto-run. You can always write code in the Text Editor that auto-runs (using the python_autoExec_v
property and the little drop down box in the top-left corner). The problem with this is that it makes it hard to open the sheet without it "going off" by itself — not what you want if you are moving back and forth between being "finished" and still "debugging" a piece.
A better way is the -auto
option:
/Applications/field.app/Contents/MacOS/field_mac64.sh -field.scratch mysheet.field -auto "someElement;somethingElse.*"
This option contains a list of element names separated by semicolons that will be automatically 'run' on startup. Running in this sense is just like pressing and holding option-left mouse on the box — see OptionClicking. The 'names' can contain regular expressions which can match multiple boxes (in the example above we run every box that has a name that begins with "somethingElse").
We're getting close. We know how to force the opening of a specific sheet and to fake option-clicking on some elements inside it. The last thing we need to do is to make sure that Field doesn't actually open any of it's windows so that the Tool Palette or the Text Editor or the canvas itself doesn't get itself in front of the art (this also prevents the docents from try editing you're artwork while you're gone).
The final option -main.class
changes the class that's responsible for launching Field.
/Applications/field.app/Contents/MacOS/field_mac64.sh -field.scratch mysheet.field -auto "someElement;somethingElse.*" -main.class field.Faceless
Setting it to "field.Faceless" sets the startup-class to a different class that the default — one that doesn't open any windows, one that doesn't even initialize any of those resources. (Note, you can also set this to be one of your own classes and handle the startup of Field completely within your own code-base.)
Now you are done — Field opens the sheet of your choosing, runs the elements of your choosing, and doesn't open any of it's windows. One last step remains, making all this happen when Field launches normally — that is, when Field is double-clicked, or even marked as "Open at Login" in the Dock.
The answer is that the default for any "command-line" parameter in Field can actually be set ahead-of-time and apply to any time that Field is launched. For example:
defaults write com.openendedgroup.Field field.scratch mysheet.field
Tells Field to always open mysheet.field — strictly, it tells Field to act as if -field.scratch myself.field
is always on it's "command line" even if you double click on it.
defaults write com.openendedgroup.Field main.class field.Faceless
defaults write com.openendedgroup.Field auto "someElement;somethingElse.*"
These two lines complete our example. Now you can open Field at log-in time and you're artwork will automatically run.
Should you tie Field and yourself in such a knot that it doesn't open, Field doesn't store anything important in its preferences domain, you can always delete it:
defaults delete com.openendedgroup.Field
will remove any of these overrides.