9 Commits

Author SHA1 Message Date
Anders Jenbo 005e7dcc23 chore: clang-tidy cleanup part 1 2026-04-03 22:57:48 +02:00
Gleb Mazovetskiy 740868af3f Update sol2 and lua
Also renames lua/lua.hpp to lua/lua_global.hpp.

The previous name broke version auto-detection in sol2, which involves
calling `__has_include(<lua/lua.hpp>)`.
2025-07-20 17:46:35 +02:00
staphen 7df7b35123 Clean up warnings and debugger errors related to the Lua console 2023-11-05 11:50:41 +00:00
Gleb Mazovetskiy cec1f1f37c Lua: Implement sandbox
1. Every script runs in its own sandbox.
2. `Events` is the only global shared state.
3. `os` datetime functions are now available.
2023-11-04 21:47:56 +00:00
Gleb Mazovetskiy b30b712cbb Lua: Add basic autocomplete in the console 2023-11-03 19:19:45 +00:00
Gleb Mazovetskiy dbfa204944 Lua: Set warn function
Previously, warnings went nowhere.
2023-11-02 15:16:31 +01:00
Gleb Mazovetskiy 5d9d5c6872 Lua: require supports loads from assets
Implements a `require` function that supports built-in modules like so:

```lua
local log = require('devilutionx.log')
```

It falls back to reading from assets, so this loads `lua/user.lua`:

```lua
local user = require('lua.user')
```

The bytecode for the asset scripts is cached, in case we want to later
support multiple isolated environments.

There may be a simpler or better way to do this.

It's good enough for now until someone more knowledgeable
about Lua comes along.
2023-11-02 02:24:06 +00:00
Gleb Mazovetskiy a9c0f5764c Console: Use a REPL environment to run code
In the REPL environment, we set `print` to print to the UI console
instead of stdout.
2023-11-01 20:05:02 +00:00
Gleb Mazovetskiy 3ea4996367 Add a basic Quake-style console
Enabled only in Debug mode.

Runs Lua similar to the `lua` CLI.
Supports multiline input with Shift+Enter.

Missing features:
1. Scrollback.
2. Input history on up/down.

Open with backtick, close with Esc.
2023-10-31 23:19:56 +00:00