document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. --LUA_SD_EVENT=/writescript.lua
  2.  
  3. local function ExecuteCmd(cmd,sid,param,result)
  4.     local param_req = ""
  5.     local msg = ""
  6.  
  7.     if (sid) then
  8.         if (param) then
  9.             param_req = \'"sessionId": "\'..sid..\'",\'
  10.         else
  11.             param_req = \'"sessionId": "\'..sid..\'"\'
  12.         end
  13.     end
  14.     if (param) then
  15.         param_req = param_req..param
  16.     end
  17.    
  18.     msg = \'{"name": "\'..cmd..\'","parameters": {\'..param_req..\'}}\'
  19.     local b = fa.request{ url = \'http://192.168.1.1/osc/commands/execute\', method = "POST", body = msg }
  20.     if (result and b) then
  21.         local s,e,b2 = b:find(\'"\'..result..\'"%s*:%s*"([^"]+)"\')
  22.         b = b2
  23.     end
  24.     return b
  25. end
  26.  
  27. -- Main script
  28. local sessionId = ExecuteCmd("camera.startSession", nil, nil, "sessionId")
  29. local captureMode = ExecuteCmd("camera.getOptions", sessionId, \'"optionNames": ["captureMode"]\', "captureMode")
  30.  
  31. if (captureMode=="image") then
  32.     ExecuteCmd( "camera.takePicture", sessionId)
  33. elseif (captureMode=="_video") then
  34.     ExecuteCmd( "camera._startCapture", sessionId)
  35.     sleep(5000)
  36.     ExecuteCmd( "camera._stopCapture", sessionId)
  37. end
  38.  
  39. ExecuteCmd( "camera.closeSession", sessionId)
');