Warning
The scripting feature is disabled by default. It is highly recommended to only enable it if you trust the source of the code you intend to execute.
YLP offers power-users the ability to extend its functionality however they like through a LuaJIT environment.
During the lifetime of this project, a few requests have been made to add support for other mods and/or add new functionality outside the project's scope. The thing is, no matter the framework one ends up creating (especially as someone who's not a programmer), it will never satisfy everyone's needs; and so the decision was made, despite the potential risks, to embed a scripting language that's both tiny and powerful.
Since most of YLP's users are technical enough and almost all of them come from the GTA modding scene, it made perfect sense to choose Lua (also dev bias).
As of now, the API is in its baby stage so expect bugs and possibly undefined behavior.
Basic API demonstrations can be found in the Examples directory.
For advanced users, the JIT and FFI libraries are open. debug is not. If you experience crashes or instability with certain shared modules (JSON/XML parsers, web scrapers, etc.) try disabling jit either for those specific modules only or for your entire plugin.
To have type hints in your code editor, follow these steps:
-
Install Lua Language Server (VS Code Extension, GitHub repository).
-
Download the /LuaLS folder and note down its save path.
-
For Visual Studio Code users, create a
.code-workspacefile in your plugin folder (next to yourmain.luafile) and paste this in it:{ "folders": [ { "path": ".", }, ], "settings": { "Lua.runtime.version": "LuaJIT", "Lua.runtime.enableLuaJITExtensions": true, "Lua.workspace.checkThirdParty": false, "Lua.workspace.library": [ "C:\\Path\\To\\LuaLS" ], "Lua.runtime.builtin": { "debug": "disable" }, } }
Documentation for YLP's bindings are in the /Docs folder.
The embedded version is v2.1 with 3.0 extensions backport. These extensions include:
-
Bit Operators:
local x = a & b local y = a | b local z = a ~ b local w = ~a local foo = a << 4 local bar = a >> 2 local baz = a ~>> 0
-
C-style Operators:
if a != b then ... end if !value then ... end if a && b then ... end if a || b then ... end
-
Ternary:
local x = condition ? first : second
-
nilCoalescing:local x = value ?? fallback local y = maybeTable?.value local z = Class:MaybeMethod?(args)
-
Compound Assignment:
i += 1 bs &= mask str ..= "foo"
-
Other Additions:
continue const x = 123 local fn = (x, y) => x + y local n = 1_000_000
You can learn more about 3.0 extensions at LuaJIT#1475.