If I remove the sdcard after the script has been loaded, it still works so I dont think that the cam fetches instructions from the memory card each time... so I would exclude the sdcard as the cause of the problem.
You mean you remove the SD card with the power on? On my cameras, opening the door to get to the card cuts the power. And the Lua interpreter might be loading chunks of code as it needs them, if the whole script doesn't fit into memory.
I just encountered a strange Lua load bug that may or may not be related to this problem.
I've been working on a long Lua program, repeatedly making small changes and saving the new Lua file on the SD (32G) card. I added some print() statements, and when I saved the new file on the card, they didn't print! After much experimenting, I found that I could get them to print by reloading the same Lua script file. I can't reproduce it with smaller files.
It must be running the old Lua file, even though it's no longer on the card, since the script ran but without the changes. This is with turning the camera off, taking out the card, saving the new file on the card (over the old one), and restarting CHDK, then running the script.
Unless the Lua script is persisting in camera memory, this means that it's loading the old, deleted file and running it. Eventually, that part of the card would be re-used, and crash the script.
Easy way to test if this is your bug would be to re-load the script manually after powering on.
Anyone familiar with the Lua loader that might be able to explain this? Thanks.
CHDK 1.2.0-2267
sx260hs 100b