Appkit: /main.lua code sample - Stingray Lua API Reference
--[[
Engine lua startup file for the Appkit, for use in the Project's settings.ini.
Searches for a `content/script/project.lua` file in the Project's folder. If no
project lua is found, or if the project.lua does not define its own `init`,
`update`, `render` or `shutdown` hooks, then the Appkit.SimpleProject will be
used to provide a default project implmenetation with basic Application, Flow
and Editor Test Level support.
]]--
-- The SimpleProject is a simple fallback project.
SimpleProject = require 'core/appkit/lua/simple_project'
-- The project can provide following lua script file to extend SimpleProject
-- behavior or circumvent SimpleProject by implementing the core engine lua hooks directly.
-- Alternatively the project can use its own lua startup script via settings.ini, and still
-- use appkit lua modules.
local app_settings = stingray.Application.settings() or {}
local project_boot_script = app_settings.project_script or "script/lua/project"
if stingray.Script.exists(project_boot_script) then
require(project_boot_script)
else
print "Appkit main.lua: No Project-specific entry lua found. Using SimpleProject behavior from core/appkit/lua/simple_project."
end
-- Set the project behavior extension class
if Project then
SimpleProject.extension_project = Project
end
-- Test if the project lua defines the core engine lua hooks. If not, use the
-- SimpleProject.
-- The project can choose to override each engine hook individually.
if not init then
init = SimpleProject.init
end
if not shutdown then
shutdown = SimpleProject.shutdown
end
if not update then
update = SimpleProject.update
end
if not render then
render = SimpleProject.render
end