restore() not called - LUA Scripting - CHDK Forum

restore() not called

  • 3 Replies
  • 3968 Views
restore() not called
« on: 25 / June / 2011, 18:59:47 »
Advertisements
Hi! I remember having read that a Lua script can do some clean-up when interrupted by defining the function "restore()". However, I don't seem to get this to work:

Code: (lua) [Select]
function restore()
  printf("Restoring camera")
  -- unlock AF
  set_aflock(0)
  -- close log
  log:close()
  -- restore the original dial mode
  capmode.set(initial_mode) 
  -- restore display
  set_backlight(1)
end

It should print "Restoring camera" when I press the shutter to interrupt the script, but it does not. All I get is the usual "*** INTERRUPTED ***" message. If it helps, "printf" is defined elsewhere as "print(string.format(...))".

Is this supposed to work? At this point, I don't even know if I dreamed it.

*

Offline reyalp

  • ******
  • 14125
Re: restore() not called
« Reply #1 on: 25 / June / 2011, 19:06:28 »
Yes, it is supposed to work.
Don't forget what the H stands for.

Re: restore() not called
« Reply #2 on: 25 / June / 2011, 19:53:15 »
Hmm, it does work... I'd have sworn it didn't, maybe I hit some odd scenario. I'll post back if I get to reproduce it. Thanks!

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: restore() not called
« Reply #3 on: 15 / July / 2011, 16:10:45 »
And now I'm having problems with it too. It used to work, and now that I've fiddled with the script code more it doesn't... hmh.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal