Note that this change will not work with chdkptp as it wants to run scripts on the camera when it connects. Conventional PTP image download from your PC should work though.
FWIW, there's a couple ways you could work around this.
1) chdkptp -nolua can be used with single file download (not mdownload) to avoid any lua calls. Problem: You need to know the exact filesnames, which is only available using script. You could iterate over the possible file and directory names, but that would be pretty slow/ugly.
2) with chdkptp 1.3, you could use killscript to terminate the script, download as normal, and then restart the script over ptp. However, any script state would be lost.
Both of these could be made cleaner using the message interface, as you suggest in the next post. For #1 you could send a message that gets a list of file names, and then run lua in chdkptp to iterate over that with download. For #2, you could send a message that tells the script to save any required state and quit cleanly. The script could check if it's being started from ptp since the standard a,b,c etc variable will be nil unless you explicitly set them before the loadfile()() call.