Canon Camera Hackers Manual page 111

Camera hackers manual berthold daum
Table of Contents

Advertisement

102
C H A P T E R 5
Scripting
Some standard libraries are already included in Lua, such as:
Basic library for some core functions
f
Input and output library
f
Operating system facilities library
f
String manipulation library
f
Mathematical functions library. The CHDK version of this library differs
f
substantially from the standard version because all functions dealing
with floating point numbers have been removed (section 5.4.1).
Other libraries can easily be added to Lua by placing them into the folder
/CHDK/LUALIB. Before such a library can be accessed in a script, it must be
loaded. This is done with the statement:
require("library_name")
where the library name is written without the suffix ".lua". It is possible to
assign the result of function require() to a variable. Often libraries con-
struct a table containing all public functions and values defined in the
library, and return this table to the loader. The loader may then retrieve
these functions and values. For example:
props = require("propcase")
id = props.DISPLAY_MODE
Here the library propcase.lua has returned the table props containing a
value under key DISPLAY_MODE. This technique helps avoid name clashes
when several libraries are used at the same time.
The following libraries are automatically loaded:
Lua core functions
The core library implements functions such as the already discussed
pcall(), error(), or print(). The following functions can also be useful:
dofile(fname)
tonumber(p,b)
tostring(p)
type(p)
Loads the specified file as a new Lua script and executes it.
Converts p to a number to the specified base b. If b is
omitted, a base of 10 (the decimal system) is assumed.
Converts the parameter p into a string.
Returns the type of p. Possible return values are: "nil",
"number", "string", "boolean, "table", "function", "thread",
and "userdata".

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents