Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 06-17-2017, 09:37 AM   #1
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default reateam reascript - gui examples, just work Development environment opened?

per example, this script: https://github.com/ReaTeam/ReaScript...w_At_Mouse.lua

it runs when i have Development Environment Opened and click run, but not when i click in the toolbar bar button i created for this or when i press a Keyboard Shortcut.

What am i doing wrong?
Thanks!
deeb is offline   Reply With Quote
Old 06-17-2017, 02:16 PM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

I don't know why it works in the IDE, but when ran standalone the window disappears as soon as it can because the script finishes its execution.

Add this bit of code to increase the lifespan of the script so that it only finishes when the window is closed:
Code:
function loop()
  if gfx.getchar() >= 0 then
    reaper.defer(loop)
  end
end

reaper.defer(loop)
cfillion is offline   Reply With Quote
Old 06-18-2017, 07:52 AM   #3
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

thanks man! that makes it work altho i don't know exactly what those instruction are making.

can you tell me what : gfx.getchar does? and what reaper.defer(loop) means?

Thanks a lot!
deeb is offline   Reply With Quote
Old 06-18-2017, 01:38 PM   #4
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Have you looked at the API documentation?

In summary:
  • getchar returns -1 when the window is closed, 0 if no key is pressed and a positive number otherwise.
  • defer runs the given function on the next internal timer tick (EDIT: 30-50Hz). It also disables the undo point that running a script usually creates.

Last edited by cfillion; 06-19-2017 at 04:29 PM.
cfillion is offline   Reply With Quote
Old 06-18-2017, 02:03 PM   #5
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

i searched but didn't find , i think i just googled tho. All makes more sense now. Thank you for that! all good peace!
deeb is offline   Reply With Quote
Old 06-18-2017, 02:11 PM   #6
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

The documentation can be accessed straight from REAPER: Help > ReaScript documentation. It's way more up to date than anything you'll find online since this one is generated specifically for your current version of REAPER and loaded extensions.

X-Raym also frequently updates a prettier one here: https://www.extremraym.com/cloud/reascript-doc/.

Last edited by cfillion; 06-18-2017 at 02:18 PM.
cfillion is offline   Reply With Quote
Old 06-19-2017, 03:53 PM   #7
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

That example script is mine - it closes the window right away because it's not meant to be a full script. It's just a demo for getting the window position.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 06-19-2017, 05:21 PM   #8
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 4,812
Default

Quote:
Originally Posted by cfillion View Post
The documentation can be accessed straight from REAPER: Help > ReaScript documentation. It's way more up to date than anything you'll find online since this one is generated specifically for your current version of REAPER and loaded extensions.

X-Raym also frequently updates a prettier one here: https://www.extremraym.com/cloud/reascript-doc/.
Quote:
Originally Posted by Lokasenna View Post
That example script is mine - it closes the window right away because it's not meant to be a full script. It's just a demo for getting the window position.
Thank you both for everything. : )
deeb 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 12:42 PM.


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