Skip to content

Commit 7ba6232

Browse files
committed
#716 Fix "context.feedback_value.color" not containing nil if no color set
1 parent f854595 commit 7ba6232

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

main/src/domain/lua_midi_source_script.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@ impl<'a> MidiSourceScript for LuaMidiSourceScript<'a> {
9494
self.env
9595
.raw_set(self.y_key.clone(), y_value)
9696
.map_err(|_| "couldn't set y variable")?;
97-
let context_lua_value = self.lua.as_ref().to_value(&context).unwrap();
97+
let mut serialize_options = mlua::SerializeOptions::new();
98+
// This is important, otherwise e.g. a None color ends up as some userdata and not nil.
99+
serialize_options.serialize_none_to_null = false;
100+
serialize_options.serialize_unit_to_null = false;
101+
let context_lua_value = self
102+
.lua
103+
.as_ref()
104+
.to_value_with(&context, serialize_options)
105+
.unwrap();
98106
self.env
99107
.raw_set(self.context_key.clone(), context_lua_value)
100108
.map_err(|_| "couldn't set context variable")?;

0 commit comments

Comments
 (0)