Some backwards-compatible changes to the main script
The design of the App table in Lua was originally created to work with mobile, which has a more restricted program flow. The application calls App:Start() once to initialize it, and then will continually call App:Loop() until the function returns false. These two functions are found in the file "Scripts\App.lua".
Since we are focused on the PC now, it does not make sense to keep this structure. It also makes it more confusing to teach scripting. A conventional program layout with one main script is much simpler than having two functions that are called by the interpreter itself. We are going to transition to a conventional program layout in a way that doesn't break compatibility with existing scripts.
First, if you do nothing and keep the App.lua script as it is, your program will continue to work. However, your App.lua file no longer is required to contains the App table, or the two Start() and Loop() functions. If your App.lua file just contains text like this, it will work just fine:
window = Window:Create() context = Context:Create(window) world = World:Create() local camera = Camera:Create() camera:Move(0,0,-3) local light = DirectionalLight:Create() light:SetRotation(35,35,0) model = Model:Box() model:SetColor(0.0,0.0,1.0) while true do if window:Closed() or window:KeyHit(Key.Escape) then return false end model:Turn(0,Time:GetSpeed(),0) Time:Update() world:Update() world:Render() context:Sync() end
Doesn't that code look simpler?
Second, we are going to introduce a new file called "Main.lua" into the project template, and remove App.lua from the original template. If both App.lua and Main.lua are present, then App.lua will be called. If only Main.lua is present, then it will be used. This means that new projects will use our preferred method of calling Main.lua, but existing projects will be unaffected, even when the project is updated.
All existing code examples in the documentation will continue to work when pasted into App.lua or Main.lua.
TLDR: Changes are coming but it won't affect your existing projects.
8 Comments
Recommended Comments