To load and initialize a plugin from your script, just add a @REQUIRE preprocessor command for each plugin at the top of the script. For example, if your script requires the AVCodec plugin, you should add the following line at the top of your script:
@REQUIRE "avcodec" |
The @REQUIRE preprocessor command also allows you to pass additional initialization options to the plugin and it also allows you to specify the minimum version of the plugin required. See REQUIRE for details.
You can also tell Hollywood to automatically load all installed plugins by setting the
AutoLoadPlugins tag to True in the @OPTIONS preprocessor command.
This can be done like this:
@OPTIONS {AutoLoadPlugins = True}
|
With this code, Hollywood will always load all installed plugins when running your
script. Note, however, that even when setting the AutoLoadPlugins tag to True, it might
still be necessary to call @REQUIRE on certain plugins. This is because
several plugins need custom initialization code which is only run if you explicitly
call @REQUIRE on them. For example, plugins which install a display
adapter will not be activated unless you call @REQUIRE on them.
So you need to check out the plugin manual to find out if the respective plugin needs
a @REQUIRE call or not. So all things considered, the easiest way
is to just call @REQUIRE for all plugins needed by your script.
When you compile your script into an executable, the generated executable will only load
the plugins that the script has declared via @REQUIRE preprocessor
commands. If you want your compiled executable to load all plugins that are in the same
directory as your executable, then you have to set the AutoLoadPlugins tag to True
in the @OPTIONS preprocessor command as well. If AutoLoadPlugins is
set to True, all plugins that are stored in the same directory as your compiled
executable, will automatically be loaded on startup, otherwise only the ones that
have a corresponding @REQUIRE preprocessor command will be
loaded. See OPTIONS for details.
Alternatively, when compiling executables you can also tell Hollywood to link the
plugins required by your script into the target executable. This can be done by setting
the Link tag of the @REQUIRE preprocessor command to True, e.g.
like this:
@REQUIRE "avcodec", {Link = True}
|
In that case you don't have to care about copying required plugins to the location of your executable because all required plugins have been linked to the executable.
Note that when enabling automatic loading of plugins by setting AutoLoadPlugins to True,
you can also choose to skip certain plugins by simply renaming them: Plugins whose
filename starts with an underscore character ('_') will not be loaded automatically
by Hollywood. As an alternative, you can also use the -skipplugins
console argument to tell Hollywood to skip automatic loading of certain plugins. Plugins
which have not been loaded at startup, can be loaded later by using the @REQUIRE
preprocessor command or the LoadPlugin() function.