How to create and run as well as manage Lua scripts
Jump to:
To run a Lua script
- Open the
Lua Script Library through
. Use the appearing dialog to load, save, and execute Lua scripts as well as to create new ones.
- Select the script to be run.
- Click
Execute Script.
Top
To run a Lua script when launching
Netfabb
A command-line option runs a Lua script in
Netfabb when you launch it.
- Navigate to the installation folder of
Netfabb, typically
C:\Program Files\Autodesk\Netfabb Ultimate 2023\.
- Find the
netfabb.exe executable and create a shortcut to it.
- Edit the shortcut and add
"/startluascript=path\to\luascript.lua" to what is already specified in the
Target: field, adjusted for your Lua script file's respective path and name.
- Click
Apply.
With a shortcut provisioned like this, you can have
Netfabb load a Lua script right at launch.
Note: You cannot provide start parameters for the script itself similar to how you would call the Lua interpreter with the script name and start parameters for that script. Instead, you will have to use different means to communicate the startup parameters, such as by writing a file, for example. For a working example for this visit
this response in the Netfabb forum.
Using the included executable
netfabb_console.exe,
Netfabb starts with as little in the ways of application windows as possible, and also terminates when the script is finished:
netfabb_console.exe -l
<your Lua script>
Note: This is still not a fully headless mode and still requires graphics hardware and display to run.
Top
To add a Lua script to the library
The library has two options to make a new script available for execution in
Netfabb:
- Duplicate an existing script: Right-click an existing script and choose
Duplicate. The duplicate is added to the library with the
_Duplicated suffix.
- Create a new script: Add the bottom of the library window, click
New Script. In the new dialog, you may provide a
name and a
description. You can now
type or
paste your Lua code into the code window, or use the
Import Script function to load code from a file.
Top
Editing a Lua script
To begin editing a script, choose
, select the script to be edited, and click
Edit Script.
Ctrl+Z is available for undoing changes.
Use
Check Syntax to have
Netfabb test for mistakes like missing quotation marks or closing brackets.
To save any changes, click
Apply Changes, otherwise click
Cancel to discard them. Both buttons close the dialog and return to the library.
Top
Using the debugger
To begin debugging a script, choose
, right-click the script to be debugged, and choose
Run Debugger from the context menu.
Flow controls
- Next steps through each line of code. It does not jump into functions, however, but executes them whole.
- Step into follows a line's jump into functions so that you can step through the function's individual lines.
- Step out executes the rest of the function immediately and returns to the line after the one that called the function.
Note: Any remaining functions called on the same level and in the same line are executed immediately as well. If you require a deeper insight into executing multiple functions, even nested functions, consider using breakpoints instead or in addition to stepping into and out of functions.
- Continue executes the rest of the entire script and closes the debugger.
Debugging read-outs
- Global variables: Variables that are always defined and available
- Local variables: Variables which are valid and available in the current scope only
- Breakpoints: Position the cursor on a line, verify that the correct line is displayed, such as
lua:18, then click
Add to place a breakpoint. Select a breakpoint in the list and click
Remove to discard it.
- Log: Any logging calls (using
system:log()) are reproduced here regardless of the current logging channel.
- Stack: Displays the current stack counter
Top