TV mode and setting exposure time

I want to use my a4000 to take long exposures through a telescope, EDIT: (via a USB connection, without changing zoom). I've read a fair amount of the scripting manuals on the CHDK site, but I don't seem to be able to override the settings from the CHDK overrides menu. In Lua, the statement:

I want to take long exposures at a user-defined exposure time, from a USB connection, without changing zoom. Can that be done without a script?

It will ultimately use a script if you are doing it with a PTP client over USB. (edit: although if you set the override in the menu, shooting over ptp should honor that override setting)

in the chdkptp client, you should be able to doshoot -tv=30

This will use set_tv96_direct under the hood, so if that actually doesn't work you would still have a problem. However, set_tv96_direct should work. You need to call it outside of half shoot, and you need to give the value in APEX*96 units.

If the example script msl gave you doesn't result in a 30 sec exposure, there is a problem and we will probably need more details to diagnose it.