How to expose mapargs in the Lua Debugger
Some users sometimes wonder how to expose the data payload related to an event that an action is associated with while debugging their Lua scripts.
As you may know, the function argument mapargs, is a Lua table whose keys provide the context in which the action is being invoked along with any action specific argument and parameters. This context includes the application, screen and control the action was associated with, the currently focused control, and custom event data.
However, all the information is not automatically loaded to the debugger since an increasing amount of data passed into the Lua function callbacks, especially for short lived functions, may cause an unnecessary overhead.
This could be entirely avoided, by providing a context table with a metatable avoiding the processing until the data is absolutely required. This can be achieved by using a plugin option called lazy_context* that you can pass to the engine on the Storyboard Simulator Configuration, on the Extra Engine Options section, that will force the debugger to load this information. Add:
-olua,lazy_context=0
If we set a breakpoint** inside the function and simulate again we can observe the following difference when inspecting mapargs:
Before:
After:
If you need to access the payload data in your function, you can call the function gr_context_get_event_data, which is essentially a pointer to a Lua table containing this data.
--
Tip: ways of inspecting mapargs:
- On the Variables section as shown above
- Writing mapargs on the Expression tab:
- Typing mapargs on the Interactive console tab:
*Note: lazy_context plugin option is available for Storyboard 7.0 and higher
**Note: Debugger is not switched on by default. To start the Debugger, open Storyboard Simulator Configurations, on Storyboard Engine section go to Lua, and select the checkbox Enable Lua Debugger.
Comments
Please sign in to leave a comment.