Execute Lua scripts with hostlua & notepad++

Revision as of 09:32, August 21, 2013 by Msl (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
593pages on
this wiki

The CHDK hostlua environment allows the following commands directly from the editor:

  • execute CHDK Lua scripts on a Windows PC
  • execute CHDK Lua scripts on the camera
  • upload files to the camera
  • running of chdkptp commands

To run CHDK scripts under Windows, hostlua used from CHDK-trunk/tools/hostlua. This is a Lua compiler with the special features of CHDK, such as integer or limited mathematical functions. Deposited are not camera-specific functions. These are largely supplemented by an emulator script.

For executing scripts on the camera will used chdkptp.



  • Unzip the folder "hostlua" from to any destination.
  • Run the file "create_config.cmd" in the subfolder "hostlua\plugin_NppExec"
  • Configuration of Notepad++ console

First use of NppExec:

  • Installation of the plugins via Noteoad++ menu: Settings => Import => Import Plugin(s)...
  • Select "hostlua\plugin_NppExec\NppExec.dll"
  • Finish Notepad++
  • Copy all files from subdir "hostlua\plugin_NppExec\config" to
    • Installed Notepad++: "C:\Users\<username>\AppData\Roaming\Notepad++\plugins\config"
    • portable Notepad++: "...\Notepad++Portable\Data\settings\plugins\config"

NppExec is already in use:

  • Finish Notepad++
  • Add/Update the content of "hostlua\plugin_NppExec\config\npes_saved.txt" in the file npes_saved.txt.
  • This file is in:
    • Installed Notepad++: "C:\Users\<username>\AppData\Roaming\Notepad++\plugins\config"
    • portable Notepad++: "...\Notepad++Portable\Data\settings\plugins\config"
  • Check the setting in Notepad++ menu "Pugins => NppExec => Console Output...{ANSI/ANSI}"
  • Recommendation: activate the setting in Notepad++ menu "Plugins => NppExec => Save all files on Execute"



Lua files are always subjected to a simple syntax examination. File locations:

  • CHDK files: "hostlua\A\CHDK\..."
  • Lua libraries: "hostlua\A\CHDK\LUALIB\"
  • Lua scripts: accepted from all folders, copy to the camera "A\CHDK\SCRIPS\".
  • PTP command files have the extension ".ptp", accepted from all folders.

Available commands in Notepad++ console:

  • CHDK LUA local

> Execute Lua scripts in the CHDK script emulator.

> Bit operations do not work (known bug).

  • CHDK LUA remote

> Transferring files to the camera and run Lua scripts on the camera.

> The Lua command set_record() can be used despite PTP connection.

  • CHDK LUA remote output

> The same as "CHDK LUA remote".

> In addition, the outputs of the script console output to the Notepad++ console at script end.

> Scripts will run a bit slower compared to "LUA CHDK remote".


> Processing of PTP commands with chdkptp. Command list under "hostlua\bin\chdkptp_USAGE.TXT" or usage.txt.


  • Open a CHDK Lua file in Notepad++.
  • Start console command in Notepad++ menu "Macro"
  • Repeat last console command: CTRL+F6


Around Wikia's network

Random Wiki