Old 07-02-2017, 02:21 PM   #1
Airal
Banned
 
Join Date: Nov 2015
Posts: 406
Default Hack for inter-script communication(Python in lua)

One can call python from lua using a hack(and I suppose vice versa).

The idea is to use exec and SetExtState,

lua:

reaper.SetExtState("PyExec", "Exec", "winsound.PlaySound('Bell.wav', winsound.SND_FILENAME)", 0);
rll.Action("_RSa5517e9a84a6ab5695f28c117f9696f483b 04e51");

python:

import winsound;

if RPR_HasExtState("PyExec", "Exec") == 1:
exec(RPR_GetExtState("PyExec", "Exec"))
RPR_DeleteExtState("PyExec", "Exec", 0);

or for continuous version:

def NoUndo():
if RPR_HasExtState("PyExec", "Exec") == 1:
exec(RPR_GetExtState("PyExec", "Exec"))
RPR_DeleteExtState("PyExec", "Exec", 0);
RPR_defer("NoUndo()");

RPR_defer("NoUndo()");


The problem is that it's quite slow as I guess it has reinit the script each time but it does work. Possibly could use defer to keep the script active. It pauses my script for about 2 seconds but it does play a sound. Useless for my metronome app though ;/ Maybe the winsound is synchronous though as the pause seems to last as long as the song. Edit: Yeah, add winsound.SND_ASYNC and it works The scripts have to be in sync though as if one closes one and not the other they can get out of sync. This does extend the power of lua a bit because python scripting has more abilities to load external code. [Edit: Unfortunately SND_NOSTOP causes the script to fail for some reason making making multiple sounds at once impossible except for extreme hacks(pre-generating all combinations of possible sounds)]



This might make it easier in some cases to extend some old scripts.

Last edited by Airal; 07-02-2017 at 07:21 PM.
Airal is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:49 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.