CHDK Lua script environment (for Windows) - page 5 - LUA Scripting - CHDK Forum

CHDK Lua script environment (for Windows)

  • 46 Replies
  • 19880 Views
Re: CHDK Lua script environment (for Windows)
« Reply #40 on: 18 / November / 2024, 03:59:22 »
Advertisements
@msl :  does the emulator support the new CHDK scripting header format for defining users parameters ?

  i.e. :
Code: [Select]
# interval          7      "Shot Interval (Sec)" { Burst Fast 2 3 4 5 10 15 20 30 45 60 90 120 180 240 300 }

I installed hostlua 4.2.001 and can run grid_viewer.lua in CHDK Lua local keypad, but this file has still the classic param convention,
Code: [Select]
@title Grid Viewer
@chdk_version 1.4
#wide_mode=1 "wide display align" {left center} table
#mem_debug=false "show memory usage"
NOT the new convention quoted by waterwingz. Has this never been resolved?

*

Offline reyalp

  • ******
  • 14128
Re: CHDK Lua script environment (for Windows)
« Reply #41 on: 18 / November / 2024, 14:24:08 »
NOT the new convention quoted by waterwingz. Has this never been resolved?
Looking at the included emu.lua in https://forum.chdk-treff.de/download/file.php?id=2890, it does look like it should support the # syntax.
Don't forget what the H stands for.

Re: CHDK Lua script environment (for Windows)
« Reply #42 on: 19 / November / 2024, 04:04:59 »
Well, not sure whats going wrong. emu.lua included as v 0.4 in distribution
A simple test - modification of grid-view.lua for new parameter syntax in header for wide_mode:
Code: [Select]
@title Grid Viewer
@chdk_version 1.4
OLD: #wide_mode=1 "wide display align" {left center} table
# wide_mode     1     "wide display align"   { left center }

results in:
Code: [Select]
--- RUNTIME ERROR ---------------------
 File: grid_viewer_mod.lua
 Line: 90
  Msg: attempt to index global 'wide_mode' (a nil value)
---------------------------------------
:blink:

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: CHDK Lua script environment (for Windows)
« Reply #43 on: 19 / November / 2024, 10:57:50 »
Code: [Select]
# wide_mode     1     "wide display align"   { left center }

 :blink:
Maybe there must not be space after '#', maybe it needs the '='.  :-[
All lifetime is a loan from eternity.

Re: CHDK Lua script environment (for Windows)
« Reply #44 on: 19 / November / 2024, 11:02:57 »
... I am just taking inspiration from https://chdk.fandom.com/wiki/Ultimate_Intervalometer
all params are formatted like this

*

Offline reyalp

  • ******
  • 14128
Re: CHDK Lua script environment (for Windows)
« Reply #45 on: 19 / November / 2024, 14:42:48 »
... I am just taking inspiration from https://chdk.fandom.com/wiki/Ultimate_Intervalometer
all params are formatted like this
Yes, it looks like the parameter code in emu.lua is stricter than what CHDK uses, it requires the = and no space after the #.


https://chdk.fandom.com/wiki/CHDK_Script_Header#Lua_Shorthand_Parameter_Syntax does describe space after the # being allowed and the = being optional, so it would be good to update emu.lua to support that, but for now if you just use the stricter form it should work.

FWIW chdkptp (in SVN, not the latest binary build or the version included with package in this tread) includes a Lua parser which correctly handles both forms in chdkmenuscript.lua, but it's written for 5.3 and depends on some other chdkptp functions so it wouldn't be a drop in for emu.lua. The 'camscript' command can be used to convert menu values to globals, among other things.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14128
Re: CHDK Lua script environment (for Windows)
« Reply #46 on: 17 / December / 2024, 23:38:16 »
In CHDK trunk 6298-6306, I updated the hostlua scripts:
It now uses an adapted version of the chdkptp param parsing code I mentioned in the previous post. This doesn't exactly match every quirk to of the CHDK C code, but it should be much closer, and does handle ultimate.lua correctly.

I also added functions to camera_funcs.lua which were added to CHDK after the most recent release of hostluaPortable, and fixed some that were broken. Support for rawop is included, but some functions (the raw value / ev conversions, and histogram range) require a recent build of CHDK hostlua since they use fmath

A zip with current scripts and hostlua compiled from the current trunk is available from:
https://app.box.com/s/8yrlmlvap5v55bwx2j3tv611h43indxv

To use the updated functionality with hostluaPortable, you can just unzip the files to the bin directory, overwriting existing files.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal