PDA

View Full Version : Global Functions?


Gibbz
02-15-2006, 09:46 AM
Im trying ot make a global function for a callback.

However i do have some issues when I try various methods

Method 1

global myAnimate
fn myAnimate = ()

Method 2
global myAnimate()
fn myAnimate = ()


What am i doing wrong here?

Aearon
02-15-2006, 10:15 AM
method 1 seems to work fine here

but shouldn't the following be possible?

global fn = test()

Gibbz
02-15-2006, 10:36 AM
hrmm i think my problem arrises from a rollout opening another rollout.... Is there a way i can access the rollout

eg rollout1.rollout2.myfunction() ?


when i use a global with any kind of braketing it causes errors....

When i dont use the brakets i get the following error

>> MAXScript Callback script Exception: -- Type error: Call needs function or class, got: undefined <<

Bobo
02-15-2006, 03:27 PM
method 1 seems to work fine here

but shouldn't the following be possible?

global fn = test()


Of course not.
Actually, you probably meant

(
global fn test = (print "Test")
)

This does not work because the Parser expects a name of a variable after the reserved keyword global, but finds another reserved keyword fn. So it says:


-- Syntax error: at function, expected name

The correct way is (as you discovered yourself)

(
global test
fn test = (print "Test")
)

Aearon
02-15-2006, 09:23 PM
Actually, you probably meant

actually, i can't even remember what i meant haha

maybe i shouldn't allow myself to post at certain times of the day and in certain situations

Gibbz
02-15-2006, 10:07 PM
does it need to be in brakets?

like you have posted

(
gloabal myfunction
fn myfunction(print "boo")
)

then to call the function as per normal just use myfunction() ?

Thanks

Bobo
02-16-2006, 02:19 AM
does it need to be in brakets?

like you have posted

(
gloabal myfunction
fn myfunction(print "boo")
)

then to call the function as per normal just use myfunction() ?

Thanks


The brackets put the whole code in local scope. So without the GLOBAL myfunction, the functions would become local. This was to show that the GLOBAL declaration actually does anything.

Without the brackets, ANYTHING would become implicitly global anyway...

Gibbz
02-16-2006, 10:50 AM
ok here is rougly my code... I Still get the error. I still think it may be related to my rollout launching a rollout, where this function resides....


>> MAXScript Callback script Exception: -- Type error: Call needs function or class, got: undefined <<



global fnRadiosityLighting
fn fnRadiosityLighting =
(
print "boo!"
)

on mybutton pressed do
(
sceneRadiosity.radiosity.Reset true true

callbacks.addScript #radiosityProcessDone "fnRadiosityLighting()" id:#radiosityDone

sceneRadiosity.radiosity.Start()
)

CGTalk Moderation
02-16-2006, 10:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.