gre.SCRIPT_ROOT

gre.SCRIPT_ROOT
                    

This is a variable that is filled in by the Storyboard Engine to contain the path to the application project's scripts directory.

The gre.SCRIPT_ROOT variable provides a convenient way to reference the Lua script related resources in a location independent, project relative, manner. This variable is only applicable for filesystem based configurations.

When used in conjunction with the gre.env() function, the gre.SCRIPT_ROOT can provide an effective way to configure the search path for extra Lua modules.


Example:
                    

-- Add the scripts/<os>-<cpu> to the Lua file resolver for require statements
-- ie ..../scripts/linux-x86
local target = gre.env({"target_os", "target_cpu"})
local extra_path = string.format("%s/%s-%s/?.lua;", gre.SCRIPT_ROOT,
target.target_os, target.target_cpu)
package.path = extra_path .. package.path