CHDK allows you to automate your camera by running "scripts", small and simple programs written by end-users and executed on the camera. Currently, CHDK allows you to use scripts written in Lua (filetype: *.lua) and uBASIC (filetype: *.bas). The file extension indicates how the script should be parsed. There are scripts for exposure bracketing, focus bracketing, intervalometer and many more.
Running a scriptEdit
- Download or write your own script and place it in the chdk/scripts/ folder of your SD-card with the proper extension (.lua for Lua scripts, .bas for UBASIC scripts).
- Enter the script menu, load the script, adjust the parameters to your liking and leave the menu.
- While still in <ALT> mode just press the button and the script will start. A mini console will be displayed while you run the script.
- Note: set the Review parameter in the NORMAL camera menu to "off", other options like "x sec" or "hold" will interfere with the execution of scripts.
- You may interrupt a running script by just pressing the button again. Or pause a running script by exiting <ALT> mode, if paused the script will resume right where it left off when re-entering <ALT> mode.
Running a Lua scriptEdit
- The script should be saved with the filename extension .lua in the CHDK scripts folder chdk/scripts
- Lua scripts support libraries, place these files in either chdk/scripts or chdk/lualib (see Lua syntax: Libraries).
Running a uBASIC scriptEdit
- The script should be saved with the filename extension .bas in the CHDK scripts folder chdk/scripts
Differences between Lua and UBASICEdit
uBASIC was the first scripting language supported in CHDK and is a smaller language (both in memory size and extensiveness of features). Lua came later and can be found in CHDK builds > version 0.5 / changeset 512. In general Lua scripts will use more memory and run faster. Some scripts use particular implementation details of one or the other language and will need some re-factoring (re-writing the flow and content of the program) in order to accomplish the same goals
- CHDK Scripting Cross Reference Page
- Script commands - New uBASIC and Lua scripting commands
- The script board on the [CHDK forums]
- Lua - An introduction to Lua on CHDK
- Lua Reference - Describes additional and/or changed scripting commands for the Lua scripting language
- Lua Syntax - Basic syntax for Lua scripts
- The Lua script board
- uBASIC Syntax
- Scripting Tutorial, including a description of available uBasic script commands.
- uBASIC Syntax Highlighting for BBEdit