using ptp with camera side scripts

  • 1 Replies

Offline reyalp

  • ******
  • 11031
using ptp with camera side scripts
« on: 18 / September / 2014, 23:27:10 »
This came to me in PM, but I prefer to answer questions on the public forum so others can contribute and benefit:

Hi reyalp,

I have a question dont know where to post it so directly asking from you.
I have written some small lua scripts which i can execute from ptp console using command loadfile('A/CHDK/SCRIPTS/myScript.lua')(). myScript contains following code:

repeat sleep(50) until get_shooting() == true


repeat sleep(50) until get_shooting() == false   

How do I pass parameters to my function like require shutter speed and what if i want to send more then one value? is there anyway i can send parameters to my script so it takes picture according to my required values? can i some how send this script comma separated values? please kindly give me some help regarding this matter or give me some link where i can read about functions. thank you  :)
You could just set a global variable before you run the script. So if your script starts like this
Code: [Select]
repeat sleep(50) until get_shooting() == true
You could just do
Code: [Select]
lua tv=384 loadfile('A/CHDK/SCRIPTS/myScript.lua')()
You can do this with as many variables as you want.

Alternatively, you could define a function inside your file like
Code: [Select]
function myshoot(tv,sv,av)
Then run
Code: [Select]
lua loadfile('A/CHDK/SCRIPTS/myScript.lua')() myshoot(394,768,480)
Don't forget what the H stands for.

Re: using ptp with camera side scripts
« Reply #1 on: 19 / September / 2014, 05:16:06 »
yes it worksss!! im so glad i asked this from you rather then searching forums for days to find solution. thank you so much. i'll try to post on forum rather then pm from now on. Thank you. :)
Naveed E Sahar


Related Topics