Notifications
Clear all

[Closed] Access local variable of Macroscript

 lo1

I need to be able to access variables defined in a Macroscript.

macroScript myMacro
(
	local val = 5
)

myMacro --> undefined

Is there a back door I’m missing here, or is all hope lost?

11 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

no way…

You could use a scene node as a gateway if you’re desparate

 lo1

Unfortunately I am not in control of the macroscript.

Oh well, time for plan B…

2 Replies
(@jonadb)
Joined: 11 months ago

Posts: 0

I think you can ask max the path of a macroscript, when you’ve got that then load the script into a string, insert own code somewhere, execute string…

 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

Yup, that is plan B
Thanks

that is also what i was thinking about. but you’ve asked about access. going this way you can only know about local variables existence, but can’t get/set them. you can change the code on-fly and reevaluate it, but… what is all this trouble for?

1 Reply
 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

what I meant is that I will reevaluate the macroscript after manipulating the string so that the local I need will be a global.

All this trouble btw is for trying to implement a request you made

what’s wrong with using globals? i see some people on this forum who tries to not use globals at all. guys, it’s a paranoia. first, it’s impossible to code without globals. second, max itself creates thousand of globals, and who cares if you add some more?

1 Reply
 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

The problem starts when you create globals with very common names, like “Settings”, “Image”, “Model”, etc.
One should always take care to name their globals specifically, prefixed with the name of the project.

Of course but that’s what every sensible scripter does, isn’t it ?

Just always prefix them with “global_” and you’ll be fine