Running Scripts from the Command-Line
Running scripts from the command line in Foxel allows you to automate tasks, streamline workflows, and leverage the powerful scripting capabilities of the application. Whether you're a developer looking to integrate Foxel into a larger project or a user wanting to execute specific tasks quickly, this guide will help you get started with ease.
To run scripts from the command-line in Foxel, follow these steps:
Open Windows Command Prompt: You can do this by searching for
cmd.exein the Start menu.Execute the Command: Use the following command format to run your script:
path\to\foxel\Foxel.exe -run scriptnameHere, scriptname can be either:
- The name of the shared script as it is listed in the Foxel UI (e.g.,
"script1"). This is case-insensitive. - A full path to the script file, such as
"C:\foxel\scripts\script1.lua".
Executing this command will open a window with the Foxel UI in command line mode, which does not allow for user interaction. However, a rendering context and a window are necessary to perform any required voxelization.
Automatic Shutdown
After the script is executed, Foxel will automatically shut down and close the window. This ensures that the application does not remain open after the script has completed its execution.
Exit Codes
Foxel uses the following exit codes to indicate the result of the script execution:
- 0: No error – The script executed successfully.
- 102: Script file not found – The specified script file could not be located.
- 902: Lua script execution failed – An error occurred during the execution of the Lua script.
These exit codes can be useful for troubleshooting and for integrating Foxel into automated workflows.
Command Prompt Example
To demonstrate how to run a simple Lua script in Foxel, you can create a script that loads the FxLog module and writes "Hello World!" to the console. This is a classic example that showcases the basic functionality of logging in Foxel.
Here’s the content of the script:
FxLog = require "FxLog";
FxLog.WriteTrace('Hello World!');In this script:
- The
FxLogmodule is loaded using the require function. - The
WriteTracemethod is called to output the string "Hello World!" to the console.
This example serves as a starting point for understanding how to use the logging capabilities of Foxel.
🔺 Figure 1: Command Prompt Example Output.