Writing Lua libraries (split from Night-time time-lapse) - page 2 - LUA Scripting - CHDK Forum supplierdeeply

Writing Lua libraries (split from Night-time time-lapse)

  • 10 Replies
  • 7105 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Writing Lua libraries (split from Night-time time-lapse)
« Reply #10 on: 10 / November / 2008, 16:28:06 »
Advertisements
Thanks for the in-depth lesson!  ;)

I first tried with code that had colons in strings "newlog:print(" and "newlog:close" replaced by periods, and while that ran on Ubuntu's Lua, it didn't print properly (it failed to output most characters or lines, without a warning) so I just tried the next syntax I could think of and it worked well. Should it have worked with them dots only?

I realised I'd be wasting RAM duplicating those two functions, but didn't know how to do it any other way and as you say they are tiny and people won't be opening tons of logs. You've shown a fine example for recycling those functions, but print and close functions (the io ones only obviously) need file handles for printing and closing. Since those externally defined functions wouldn't have handles unless given as arguments (and I don't want the user to do that since he's already named the log once in the command), the only ways I can see me getting out of this would be wrapping it locally (which would clearly be insane bloat for functions this tiny) or making handles global somehow (which doesn't sound good).


 

Related Topics