Notifications
Clear all

[Closed] How to define a global function in a Script Operator (PFlow)?

Okay guys, can’t figure it out and haven’t found it in the docs nor in the forum.
And it’s five o’clock in the morning and I have to go to bed. Maybe sleeping brings the answer…
I simply want to define a global function in a Script Operator in PF.
How the hell does that work? I’m sure the answer is quite simple…

This does work:

on Init pCont do 
   (
   	fn test = print "please do it"
   	test()
  )

But then I can’t call the function in “Proceed” or “Release” handler because it remains local.
But trying to put a “global” in front of it throws an error.
And defining it somewhere else doesn’t work either…

I hope I made it clear (yawn).
Please give me a hint.
Thanks a lot
Uli

2 Replies

You should not put global in front of the FN, you declare the function name global before you define the function. Also, you should name your function something more unique, test is too short for a global function.


on Init pCont do 
(
global test
fn test = print "please do it"
 )

on Proceed pCont do
(
test()
)

Are you actually getting paid to answer questions in this forum?
It’s amazing how quick the Master of MaxScript answers even such beginners questions I had.
Thanks a lot!!!
Uli
(If I should have looked more thoroughly somewhere else before then let me know – don’t want to bother you/ this forum if I had any other place to get the information from)