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

Reply
 
Thread Tools Display Modes
Old 05-14-2019, 03:44 PM   #1
silverbeetle_com
Human being with feelings
 
Join Date: Apr 2018
Location: Melbourne, AUS
Posts: 8
Default Basic Lua script with functions not working?? (Noob help!)

Hi all,

So I was working on a larger reascript in lua on mac and it was working when I saved from the ReaScript IDE but not when i hit run on the script in the actions window.

After some debugging it turned out the script fails when it has a function call.
I stripped back to a super basic example to test as follows:

Code:
function main()
    show_popup()
end

function show_popup() 
  reaper.ShowMessageBox("Popup from a function!", "Function Test", 0)
end

main()
As I mentioned it runs when i save in the ReaScript editor window, but nothing happens when i hit run on the script in the action window... WTF?!

Does anyone have any idea what's going on, I'm stumped and stuck until I resolve this.
__________________
https://silverbeetle.com
Melodic Rock Instrumental Guitarist
silverbeetle_com is offline   Reply With Quote
Old 05-14-2019, 03:47 PM   #2
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
Default

It's the order, the show_popup() has to appear, before main() is executed.

Code:
function show_popup() 
  reaper.ShowMessageBox("Popup from a function!", "Function Test", 0)
end

function main()
    show_popup()
end


main()

EDIT: sorry, that was poor thinking. The script works either way, here.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 05-14-2019, 05:22 PM   #3
silverbeetle_com
Human being with feelings
 
Join Date: Apr 2018
Location: Melbourne, AUS
Posts: 8
Default

Yeah - that did cross my mind but no difference. *scratches head*
__________________
https://silverbeetle.com
Melodic Rock Instrumental Guitarist
silverbeetle_com is offline   Reply With Quote
Old 05-14-2019, 05:24 PM   #4
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
Default

Have you tried a portable install?
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 05-14-2019, 08:08 PM   #5
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Working here as well.

Are you actually running it in the action list? The "Load" button just registers it as an action, if that's what you're clicking.
__________________
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 05-14-2019, 08:16 PM   #6
silverbeetle_com
Human being with feelings
 
Join Date: Apr 2018
Location: Melbourne, AUS
Posts: 8
Default

Thanks for the suggestion, I tried the portable install and it worked as expected which is great!

I'm just working on this mac during my commute, my normal machine would be a Windows desktop so this will get me rolling.
__________________
https://silverbeetle.com
Melodic Rock Instrumental Guitarist
silverbeetle_com 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 04:07 PM.


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