Author Topic: how do u write script?  (Read 3672 times)

RAW

  • New to the forum
  • *
  • Posts: 14
how do u write script?
« on: May 28, 2014, 11:35:53 PM »
Hello
  I guess u been ask too many times this same question.  I want to write a script so if Magic Lantern crashed (rarely happen). I want to have the script do some cleanup so I can reboot camera. Yes I crashed it so hard the camera locked up even canon menu. Somehow the ML, booted in safe mode, but was slow.
Is it possible for a script to do this?
thanks

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12183
  • Maintenance mode
Re: how do u write script?
« Reply #1 on: May 28, 2014, 11:44:42 PM »
If the camera is locked, there's not much you can do. If you find a way to take the battery out from a script, that would be something :D

A better option is to find a way to reproduce the crash and file a bug report.

l_d_allan

  • Senior
  • ****
  • Posts: 258
Re: How do you write and launch a script? (simplified baby steps)
« Reply #2 on: March 28, 2018, 07:43:55 AM »
Hope people don't mind that this Lua newbie is re-opening a stale thread to document my baby-steps to get a script to launch

The content of the OP was about attempting to use a Lua script to recover from a bricked camera. Probably not going to happen.

However, to address the question in just the Subject: How do you write a script? ...
Following are a series of simplified baby-steps to modify the existing hello.lua script.

The steps worked for me with a Canon 6d, a 5dm2, and Windows-10 computer. It may or may not work the same for other cameras and platforms:
  • Find ML/scripts directory in the unzipped directory
  • Copy hello.lua to hi_noob.lua
  • Edit hi_noob.lua and change 6th line
    print "Hello, World!"
    to
    print "Hi noob launched. Good job!"
  • Change 14th line
    name  = "Hello, World!"
    to
    name = "Hi noob (press SET here)"
  • Save file
  • Copy hi_noob.lua to the camera's flash card and put back in camera
  • Start the camera.
    Observe the camera's LCD console and check that hi_noob.lua successfully loaded.
  • If it hasn't already been done, activate the lua module and re-start the camera.
    Then confirm that the lua module has OK next to it.
  • Navigate to the MagicLantern menu tab for Scripts (currently two tabs to the left of the Modules tab on my 6d.)
  • Navigate down to select the newly added hi_test which will be identified as "Hi noob (press SET here)"
  • Push the SET button to launch.
  • Drum roll ....
    Did the expected text string with Good job! show up on the camera's LCD console?
  • Press any key to finish the script and return to 'the real world'.
  • If it works, save the hi_noob.lua some place to preclude it getting over-written at your next upgrade.

The are possibly omissions, unnecessary steps, typos, errors, misconceptions, etc. on my part. Assistance appreciated to clean up.