6 Commits
Author SHA1 Message Date
Gleb Mazovetskiy c4d819a54f Lua: Show signatures of native (non-C) functions 2023-11-06 10:42:16 +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 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 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
Gleb Mazovetskiy de6eac137b Split up lua bindings a bit
```lua
local render = devilutionx.render

local function drawGreet ()
  render.string("Hello from " .. _VERSION, 10, 40)
end
Events.OnGameDrawComplete.Add(drawGreet)
```
2023-10-26 03:48:56 +01:00