Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Leadwerks 5 beta update adds Visual Studio Code Integration for Lua



A new update is available to beta testers. This makes some pretty big changes so I wanted to release this before doing any additional work on the post-processing effects system.

Terrain Fixed

Terrain system is working again, with an example for Lua and C++.

New Configuration Options

New settings have been added in the "Config/settings.json" file:

"MultipassCubemap": false,
"MaxTextures": 512,
"MaxCubemaps": 16,
"MaxShadowmaps": 64,
"MaxIntegerTextures": 32,
"MaxUIntegerTextures": 32,
"MaxCubeShadowmaps": 64,
"MaxVolumeTextures": 16,
"LuaErrorCommand": "code",
"LuaErrorCommandArguments": "-g \"$(CurrentFile)\":$(LineNumber) \"$(AppDir)\""

The max texture values will allow you to reduce the array size the engine requires for textures. If you have gotten an error message about "not enough texture units" this setting can be used to bring your application down under the limit your hardware has.

The Lua settings define the command that is run when a Lua error occurs. By default this will open Visual Studio code and display the file and line number an error occurs on. 

String Classes

I've implemented two string classes for better string handling. The String and WString class are derived from both the std::string / wstring AND the Object class, which means they can be used in a variable that accepts an object (like the Event.source member). 8-bit character strings will automatically convert to wide strings, but not the other way. All the Load commands used to have two overloads, one for narrow and one for wide strings. That has been replaced with a single command that accepts a WString, so you can call LoadTexture("brick,dds") without having to specify a wide string like this: L"brick.dds".

The global string functions like Trim, Right, Mid, etc. have been added as methods on the two string classes, Eventually the global functions will be phased out.

Lua Integration in Visual Studio Code

Lua integration in Visual Studio Code is just about finished and it's amazing! Errors are displayed, debugging works great, and console output is displayed, just like any serious modern programming language. Developing with Lua in Leadwerks 5 is going to be a blast!


Lua launch options are now available for Debug, Release, Debug 64f, and Release 64f.

I feel the Lua support is good enough now that the .bat files are not needed. It's easier just to open VSCode and copy the example you want to run into Main.lua. These are currently located in "Scripts/Examples" but they will be moved into the documentation system in time.

The black console window is going away and all executables are by default compiled as a windowed application, not a console app. The console output is still available in Visual Studio in the debug output, or it can be piped to a file with a .bat launcher.

See the notes here on how to get started with VSCode and Lua.

  • Like 4


Recommended Comments

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...