Skip to content

User project structure

MCUmbrella edited this page Nov 24, 2023 · 1 revision

Directory

Assuming your project is called MyProject, create a new folder with the same name and create new subfolders and files according to the following structure:

  • assets/
    • textures/
      • entity/
      • item/
      • tile/
      • misc/
      • .../
    • sounds/
      • music/
      • sfx/
  • data/
    • lua/
      • main.lua

Items ending with a slash (/) are folders, items marked in italics are optional.

main.lua

main.lua is the file that controls the overall logic of your project. It is always loaded first by the engine (compared to your other scripts). This script is always required to be present in the user's project.

In addition, the following three functions must be present in this script:

function prepare()
    -- This function is called once after the engine has loaded main.lua
end

function tick()
    --[[
      This function is repeated at 60 times per second (by default) after the
      prepare function has been called. It will always be called automatically
      at this frequency unless an unexpected error occurs during script
      execution or the Engine's stop function is called.
    ]]--
end

function cleanup()
    --[[
      After Engine.stop() is called, the tick function will no longer be called
      automatically. After that, this function is called once and then the
      engine actually stops.
    ]]--
end