Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua console: Add a prelude file #6766

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Conversation

glebm
Copy link
Collaborator

@glebm glebm commented Nov 2, 2023

Runs lua/repl_prelude.lua at console initialization.

The default prelude contains global assignments for all devilutionx modules. This should save us on typing.
The console has its own environment so this doesn't affect other Lua scripts.

console-prelude

@glebm glebm enabled auto-merge (rebase) November 2, 2023 08:49
@AJenbo
Copy link
Member

AJenbo commented Nov 2, 2023

Please show an example of how to use render.string 😭

@glebm
Copy link
Collaborator Author

glebm commented Nov 2, 2023

It works for me even without the prelude:

render-string

Of course calling it once does nothing, you'd have to do it on every frame, for example here is my user.lua:

local log = require("devilutionx.log")
local render = require("devilutionx.render")
local message = require("devilutionx.message")

local function greet ()
  message("Hello from " .. _VERSION)
  print("Hello from ", _VERSION)
end
Events.OnGameStart.Add(greet)

local function drawGreet ()
  render.string("Hello from " .. _VERSION, 10, 40)
end
Events.OnGameDrawComplete.Add(drawGreet)

Runs lua/repl_prelude.lua at console initialization.

The default prelude contains global assignments for all devilutionx
modules. This should save us on typing.
@glebm
Copy link
Collaborator Author

glebm commented Nov 3, 2023

@AJenbo Rebased and added inspect and audio

@glebm glebm merged commit 4a7fa5d into diasurgical:master Nov 3, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants