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
Posts: 2,227
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 | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_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
Posts: 2,227
Default

Have you tried a portable install?
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_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: 5,883
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.
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 11:06 PM.


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