Go Back   Cockos Incorporated Forums > REAPER Forums > JSFX and ReaScript Discussion

Reply
 
Thread Tools Display Modes
Old 06-17-2017, 09:37 AM   #1
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 376
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: 1,211
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
 
Join Date: Feb 2017
Posts: 376
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: 1,211
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
 
Join Date: Feb 2017
Posts: 376
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: 1,211
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: The vast, frozen wasteland of western Canadia.
Posts: 4,214
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.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 06-19-2017, 05:21 PM   #8
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 376
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 03:11 AM.


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