Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ureq = { version = "3.4", default-features = false, features = ["rustls"] }
# the Lua syntax check of the map scripts (src/scripting.rs), Lua 5.4 as openOMSI runs
full_moon = { version = "3.0.0", default-features = false, features = ["lua54"] }
# the map's scripts run in the editor to test and debug them: Lua 5.4 as openOMSI runs it
mlua = { version = "0.10", features = ["lua54", "vendored", "serialize"] }
mlua = { version = "0.12", features = ["lua54", "vendored", "serialize"] }
# compiled map scripts (.oop, Lua or Rust): the compiler of the openOMSI Development Tools
oopc = { git = "https://github.com/openOMSI-org/openOMSI-Development-Tools", rev = "433930ba365833b70724c3f648c92fb24f3f1875" }
oop-format = { git = "https://github.com/openOMSI-org/openOMSI-Development-Tools", rev = "433930ba365833b70724c3f648c92fb24f3f1875" }
Expand Down
21 changes: 11 additions & 10 deletions src/script/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@ fn file_of(source: &str) -> Option<&str> {
/// Where the script that called a Rust function is (`print` from scripts/x.lua line 4).
fn caller(lua: &Lua) -> Option<(String, usize)> {
(1..6).find_map(|level| {
let d = lua.inspect_stack(level)?;
let src = d.source();
let f = file_of(src.source.as_deref()?)?.to_string();
let line = d.curr_line();
(line > 0).then(|| (f, line as usize))
lua.inspect_stack(level, |d| {
let src = d.source();
let f = file_of(src.source.as_deref()?)?.to_string();
let line = d.current_line()?;
(line > 0).then_some((f, line))
})?
})
}

Expand Down Expand Up @@ -464,7 +465,7 @@ fn run(setup: Setup, rx: Receiver<Cmd>, tx: Sender<Out>, wake: Option<egui::Cont
let eval = eval.clone();
lua.set_hook(HookTriggers::new().every_line().every_nth_instruction(10_000), move |lua, d| {
match d.event() {
mlua::DebugEvent::Count => {
mlua::debug::DebugEvent::Count => {
for cmd in c.rx.try_iter().collect::<Vec<_>>() {
match cmd {
Cmd::Stop => c.dbg.borrow_mut().stop = true,
Expand All @@ -483,10 +484,10 @@ fn run(setup: Setup, rx: Receiver<Cmd>, tx: Sender<Out>, wake: Option<egui::Cont
}
Ok(VmState::Continue)
}
mlua::DebugEvent::Line => {
mlua::debug::DebugEvent::Line => {
let src = d.source();
let Some(file) = src.source.as_deref().and_then(file_of).map(str::to_string) else { return Ok(VmState::Continue) };
let line = d.curr_line().max(0) as usize;
let line = d.current_line().unwrap_or(0);
let reason = {
let dbg = c.dbg.borrow();
if dbg.pause {
Expand All @@ -509,7 +510,7 @@ fn run(setup: Setup, rx: Receiver<Cmd>, tx: Sender<Out>, wake: Option<egui::Cont
}
_ => Ok(VmState::Continue),
}
});
})?;
}

// the main chunk
Expand Down Expand Up @@ -710,7 +711,7 @@ fn civil(z: i64) -> (i64, i64, i64) {

fn depth(lua: &Lua) -> usize {
let mut n = 0;
while lua.inspect_stack(n).is_some() {
while lua.inspect_stack(n, |_| ()).is_some() {
n += 1;
}
n
Expand Down