Ah, good point. I didn't know that I could use luar in a direct command line command. It didn't show up in the help (chdkptp help in bash).
The -e command line option lets you execute any of the commands you could enter at the > prompt
1. Using set_mf(1) without set_focus()
con 10> luar set_mf(1)
ERROR: :80: attempt to call global 'set_mf' (a nil value)
user code: 1
What version of CHDK are you using? The attempt to call a nil value error means it doesn't exist in your chdk build.
set_mf was added for 1.3, so it's been in the stable releases for a long time.
Returning user code 1 should however indicate that the camera supports it
No, though I don't think I've ever documented how the camera error messages in chdkptp work, so a small digression:
The "ERROR: :80" is a Lua error message, telling you the error happened on line 80 of the script.
Since you only sent one line (set_mf(1)), so how could there be a line 80? chdkptp actually sends a some library code with each command. The "user code: 1" message means the error happened on line one of your code, as it should be, since you only sent one!
3. Using set_aflock(1) before set_focus()
con 1> luar af_lock(1)
ERROR: :80: attempt to call global 'af_lock' (a nil value)
user code: 1
The correct function is set_aflock. You can use
http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page to find function names.
con 1> luar set_aflock(1)
con 2> luar set_focus(1)
con 3> luar set_focus(65490)
con 4> rs
WARNING: capture_get_data error I/O error
...
This means the camera crashed. The following messages are due to a bug in chdkptp error handling which is fixed in svn.
According to the settings in platform_camera.h aflock should work, but it's possible canon firmware settings could interfere with it. A look through the porting thread
http://chdk.setepontos.com/index.php?topic=6341 might tell you if there are known issues.
A romlog
http://chdk.wikia.com/wiki/Debugging#Camera_crash_logs_.28romlog.29 might also shed light on the problem.
It's slightly off-topic but can't my camera do manual focus? When I hit the "Manual Focus" button on the camera chdk display it comes on, but the camera still autofocusses at half shoot.
I guess you mean the MF shortcut from the help display? The way CHDK overrides work (at least if you haven't used set_mf or set_aflock) CHDK waits for the camera to AF and then applies the override. If you set an sd override distance, subsequent shots should have the override applied even though the camera will appear to AF.