๐Ÿงช Testing Phase: Lua 5.3 Runtime Removal in Progress

FiveM is currently testing the removal of the Lua 5.3 runtime in a significant platform update. All scripts in the test build now exclusively use the Lua 5.4 runtime, which has been updated to the latest version (5.4.8).

This change represents a major step forward in FiveM's scripting capabilities, but server owners and developers should prepare for potential compatibility issues when this update goes live.

๐Ÿ”„ What's Changed in Lua 5.4

The updated Lua 5.4 runtime includes several improvements and bug fixes, particularly to custom operators that were previously implemented in FiveM's custom 5.4 runtime:

  • Safe navigation operator - Enhanced with function call support
  • Table unpacking - Improved implementation
  • Compound operators - Bug fixes for more reliable operation

๐Ÿ’ก Enhanced Safe Navigation Operator

The safe navigation operator (?.) has been significantly improved and now supports function calls. Here are some examples of the new functionality:

x = nil

print(x?.foo.bar) -- nil

print(x?.foo.bar or 10) -- 10

print(x?.foo('hi').bar or 20) -- 20

x = {}

print(x.foo?.bar) -- nil

print(x.foo?.bar or 10) -- 10

print(x.foo?('hi').bar or 20) -- 20

The operator now jumps to the end of the expression rather than just skipping the current access, making it more powerful and intuitive.

โš ๏ธ Known Incompatibilities

Language Changes

  • String coercion: Arithmetic and bitwise operations no longer automatically convert strings to numbers
  • Integer overflow: Literal decimal integers that overflow are now read as floats instead of wrapping around
  • Metamethods: The __lt metamethod no longer emulates __le - must be explicitly defined
  • For loops: Numerical for loop semantics changed, control variable never wraps around
  • Labels: goto labels cannot be declared where a label with the same name is visible
  • Finalizers: __gc metamethods that aren't functions will still be called (generating warnings for non-callable values)

Library Changes

  • json.decode: No longer accepts square brackets, unkeyed values, or numbers as keys
  • print function: No longer calls tostring - functionality is hardwired (use __tostring to modify output)
  • math.random: Uses a different algorithm with a more random seed
  • utf8 library: Decoding functions don't accept surrogates by default (extra parameter for permissive mode)
  • collectgarbage: "setpause" and "setstepmul" options deprecated - use "incremental" instead
  • io.lines: Now returns four values instead of one

๐Ÿ› ๏ธ How to Test This Update

To test this upcoming change, you can switch your UpdateChannel in CitizenFx.ini to the test build:

specific/feature/luaglm_548

Test Build Downloads

โš ๏ธ Warning: This is a test build - use on development servers only, not production!

๐Ÿ“‹ Testing Your Scripts

Important: This is the perfect time to test all your server scripts before the change goes live. While Lua 5.4 is generally backwards compatible with 5.3, the changes listed above may affect some scripts.

If you were already using the lua54 setting in your manifest, you should see minimal changes. However, in the test build, the lua54 option is ignored since all scripts run on 5.4.

๐ŸŽฏ Who Should Test This

Server owners and developers should test this update if they:

  • Run custom scripts that might be affected by Lua version changes
  • Develop resources and need to verify compatibility
  • Use advanced Lua features that might behave differently
  • Use json.decode with non-standard formats

Make sure to backup your server and test thoroughly on a development environment. Report any issues to help the FiveM team refine this update before it goes live!