05-24-2016, 03:08 PM | #1 |
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 5,265
|
Lua: "reaper.xyz is unknown"
Code:
counter = 0 function loop() counter = counter + 1 reaper.ShowConsoleMsg(string.format("loop %d\n", counter)) pcall(function() gfx.hello_world = 42 end) if counter < 50 then reaper.defer(loop) end end loop() When clicking on the "Continue" button in the error dialog, the loop() function is ran only twice, instead of 50 times: Expected: No error dialog at all (because of pcall), or a least it should not abort the script when clicking on the Continue button.
__________________
🎁 Donate (PayPal) | Sponsor (GitHub) | The Endless Journey (Keyboard Ensemble) ReaPack, a package manager for REAPER | SWS 2.14 is now available in ReaPack [new!] Developer tools: Lua profiler | Interactive ReaScript | ReaPack Editor | ReaImGui Last edited by cfillion; 07-19-2016 at 06:16 PM. Reason: it's partialy fixed in v5.23pre1+v5.23pre2 :D |
07-10-2016, 12:08 PM | #2 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,353
|
Here is a workarround (with SWS extension check)
ReaScripts-Templates/X-Raym_Check if SWS is installed and download if not.lua at master · ReaTeam/ReaScripts-Templates The trick is to loop in reaper function table and store existing key (aka function names) in a table, and check if an extension function (no matter which one) exist in this table or not. It doesn't return REAPER error if it doesn't exist. EDIT: code snippet updated with new method, base don NammedCommand
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation Last edited by X-Raym; 07-15-2016 at 11:01 AM. |
07-14-2016, 08:33 PM | #3 |
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 5,265
|
It's not a perfect workaround though. pairs(reaper) seems to be giving "ghost" functions, such as:
Code:
for k,v in pairs(reaper) do reaper.ShowConsoleMsg(string.format("%s is a %s\n", k, type(v))) end -- this prints "function" reaper.ShowConsoleMsg(string.format("%s\n", type(reaper.ov_read_float))) -- but this crashes the script with the fatal "is unknown" error reaper.ov_read_float()
__________________
🎁 Donate (PayPal) | Sponsor (GitHub) | The Endless Journey (Keyboard Ensemble) ReaPack, a package manager for REAPER | SWS 2.14 is now available in ReaPack [new!] Developer tools: Lua profiler | Interactive ReaScript | ReaPack Editor | ReaImGui Last edited by cfillion; 07-14-2016 at 08:57 PM. |
07-15-2016, 11:01 AM | #4 |
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 10,353
|
I update the code snippet with a Workaround by Heda that works with NamedCommand instead of looping reaper table
way more efficient and reliable.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - Website - ReaComics - Alien 2347 - Donation |
07-15-2016, 01:10 PM | #5 |
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 5,265
|
@X-Raym Nice trick for checking SWS's presence.
Summary of the bugs/annoyances so far:
(These all affect my interactive reascript script, I guess it's kind of an edge case...)
__________________
🎁 Donate (PayPal) | Sponsor (GitHub) | The Endless Journey (Keyboard Ensemble) ReaPack, a package manager for REAPER | SWS 2.14 is now available in ReaPack [new!] Developer tools: Lua profiler | Interactive ReaScript | ReaPack Editor | ReaImGui Last edited by cfillion; 11-23-2016 at 05:23 PM. Reason: better english, trying to be clearer |
07-15-2016, 02:20 PM | #6 |
Administrator
Join Date: Mar 2007
Location: NY
Posts: 16,494
|
This is all fairly complicated under the hood. However, it should be easy for us to add an API function API_exists("function_name"), does that get you where you want to be?
|
07-15-2016, 06:59 PM | #7 |
Administrator
Join Date: Mar 2007
Location: NY
Posts: 16,494
|
On second thought, we'll do both. The next build will add APIExists("function_name"), and also treat reaper.* as a generic table with respect to getting and setting elements. So reaper.somefunction will be nil if somefunction() is not defined in the particular version of REAPER that is running the script. As a side effect you'll be able to set reaper.whatever="foo" and that will work too, though that's somewhat pointless.
|
07-16-2016, 12:02 PM | #8 |
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 5,265
|
Awesome, thank you!
__________________
🎁 Donate (PayPal) | Sponsor (GitHub) | The Endless Journey (Keyboard Ensemble) ReaPack, a package manager for REAPER | SWS 2.14 is now available in ReaPack [new!] Developer tools: Lua profiler | Interactive ReaScript | ReaPack Editor | ReaImGui Last edited by cfillion; 07-16-2016 at 04:27 PM. |
10-24-2021, 11:25 AM | #9 | |
Human being with feelings
Join Date: Dec 2016
Posts: 373
|
Quote:
|
|
10-24-2021, 11:38 AM | #10 |
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 5,265
|
Yes, extension functions too.
__________________
🎁 Donate (PayPal) | Sponsor (GitHub) | The Endless Journey (Keyboard Ensemble) ReaPack, a package manager for REAPER | SWS 2.14 is now available in ReaPack [new!] Developer tools: Lua profiler | Interactive ReaScript | ReaPack Editor | ReaImGui |
10-24-2021, 12:50 PM | #11 |
Human being with feelings
Join Date: Dec 2016
Posts: 373
|
|
10-24-2021, 01:19 PM | #12 |
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 5,265
|
With the latest SWS (2.12.1)? It works here:
__________________
🎁 Donate (PayPal) | Sponsor (GitHub) | The Endless Journey (Keyboard Ensemble) ReaPack, a package manager for REAPER | SWS 2.14 is now available in ReaPack [new!] Developer tools: Lua profiler | Interactive ReaScript | ReaPack Editor | ReaImGui |
10-24-2021, 02:32 PM | #13 |
Human being with feelings
Join Date: Dec 2016
Posts: 373
|
|
Thread Tools | |
Display Modes | |
|
|