Notifications
Clear all

[Closed] Works as .ms but not .mcr

Can anyone tell me why the following script works without the macroscript header, but not with it.

macroScript LetsGetBakedLean category:“Subdued Software” toolTip:“Open LetsGetBakedLean” icon:#(“LetsGetBaked”,1)
(
if $ != undefined then
(
fn checkDialog = (
local hwnd = dialogMonitorOps.getWindowHandle()
local dialogTitle = uiAccessor.getWindowText hwnd
“made it in: “
if (dialogTitle == “Disable Sun Slave Shadows?”) then (
uiAccessor.pressButtonByName hwnd “&Yes”
)
if (dialogTitle == “Missing Map Targets”) then (
uiAccessor.pressButtonByName hwnd “Continue”
)
if (dialogTitle == “Version control error”) then (
uiAccessor.pressButtonByName hwnd “OK”
)
true
)
dialogMonitorOps.interactive = false
dialogMonitorOps.unregisterNotification id:#test
dialogMonitorOps.registerNotification checkDialog id:#test
dialogMonitorOps.enabled = true
fileIn “$userScripts\LightRigger\LightRigger.ms”
LightRiggerTGV[3][2].sunmastmultspnr.value=0.65 – Script Errors out on this line, “no get function for undefined”

This script accesses the UI of another script, LightRigger. I am guessing that embedding all the code as a macroscript somehow changes the scope of the variables, but I don’t quite know if it can be fixed. Any thoughts?

1 Reply

If you believe the error message, then LightRiggerTGV is undefined after the fileIn.
Can you add a print to check what the value of LightRiggerTGV is?
Since the fileIn is executed in global scope, I would expect anything created inside that external script to be successfully loaded no matter what.
What is LightRiggerTGV, what scope does it live in and what does it contain (in other words, what is the [3][2] access pointing at?)