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 (file names: *.lua) and uBASIC (file names: *.bas). The file extension indicates how the script should be parsed. There are scripts for many applications like for exposure bracketing, focus bracketing, intervalometers and more available here : User Written Scripts
- 1 Running a script
- 2 Differences between Lua and UBASIC
- 3 Useful Links
- 4 Setting up a Development Environment
- 5 Other Notes
- 6 Tip for Those Who Can't Stop a Script from Automatically Running Every Time They Turn on CHDK
Running a script[edit | edit source]
Overview[edit | edit source]
- 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 script[edit | edit source]
- 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 script[edit | edit source]
- The script should be saved with the filename extension .bas in the CHDK scripts folder chdk/scripts
Differences between Lua and UBASIC[edit | edit source]
uBASIC was the first scripting language supported in CHDK. Lua came later and can be found in every CHDK build released since the year 2008. In general, Lua scripts will run faster and provide more features that uBASIC but the Lua language is not as well know as the many variants of BASIC.
Useful Links[edit | edit source]
- CHDK Scripting Cross Reference Page
- Script commands - uBASIC and Lua scripting command definitions
- The script board on the [CHDK forums]
- User written scripts
Programming in uBASIC[edit | edit source]
- uBASIC Syntax
- Scripting Tutorial, including a description of available uBASIC script commands.
- uBASIC Syntax Highlighting for BBEdit
Programming in Lua[edit | edit source]
- 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
Setting up a Development Environment[edit | edit source]
For help in setting up a Lua development environment, see Lua Development Environment.
Using these tools, scripts can be tested locally on your PC prior to being uploaded to your camera.
Other Notes[edit | edit source]
You may wish to build CHDK without some components to increase the available memory on the camera.
Tip for Those Who Can't Stop a Script from Automatically Running Every Time They Turn on CHDK[edit | edit source]
If you cant 'stop' a script from running or 'unload' it, you can connect your memory card to your computer and rename script that is auto running (example: from interv.lua to interv1.lua)